From 5a47c91d2b0f07c111729b172c28cbdc415ee136 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Sat, 23 Sep 2017 13:26:02 -0700 Subject: [PATCH] add threshold for gesture event --- app/assets/javascripts/posts.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 52ed40bad..74ff25c6c 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -25,7 +25,6 @@ this.initialize_post_image_resize_to_window_link(); this.initialize_similar(); this.initialize_replace_image_dialog(); - this.initialize_gestures(); if ((Danbooru.meta("always-resize-images") === "true") || ((Danbooru.Cookie.get("dm") != "1") && (window.innerWidth <= 660))) { $("#image-resize-to-window-link").click(); @@ -44,14 +43,18 @@ if (hasNext) { $("body").hammer().bind("panleft", function(e) { var percentage = 100 * e.gesture.deltaX / window.innerWidth; - $("body").css({"transition-duration": "0.1s", "transform": "translateX(" + percentage + "%)"}); + if (percentage < -10) { + $("body").css({"transition-duration": "0.1s", "transform": "translateX(" + percentage + "%)"}); + } }); } if (hasPrev) { $("body").hammer().bind("panright", function(e) { var percentage = 100 * e.gesture.deltaX / window.innerWidth; - $("body").css({"transition-duration": "0.1s", "transform": "translateX(" + percentage + "%)"}); + if (percentage > 10) { + $("body").css({"transition-duration": "0.1s", "transform": "translateX(" + percentage + "%)"}); + } }); }