inuyaksa / jquery.nicescroll

nicescroll plugin for jquery - scrollbars like iphone/ipad
https://nicescroll.areaaperta.com/
3.6k stars 1.67k forks source link

Ontouchmove function throws error after content is loaded #740

Open boazbch opened 6 years ago

boazbch commented 6 years ago

Hi all,

It seems that for laptops with integrated touch screen the following problem occurs when loading content dynamically:

Is there an override for this issue for laptops with touch-screen? maybe an option that can be disabled?

Thanks.

glacios commented 3 years ago

When I used bind instead of delegate for this event the error had disappeared. At the moment don't know why though

--- a/jquery.nicescroll.js
+++ b/jquery.nicescroll.js
@@ -1650,7 +1650,7 @@
           });
           self.bind(self.win, "pointerdown", self.ontouchstart);
           self.bind(_doc, "pointerup", self.ontouchend);
-          self.delegate(_doc, "pointermove", self.ontouchmove);
+          self.bind(_doc, "pointermove", self.ontouchmove);
         } else if (cap.hasmstouch) { //IE10
           self.css((self.ispage) ? $("html") : self.win, { '-ms-touch-action': 'none' });
           self.css(self.rail, {
@@ -1661,7 +1661,7 @@
           });
           self.bind(self.win, "MSPointerDown", self.ontouchstart);
           self.bind(_doc, "MSPointerUp", self.ontouchend);
-          self.delegate(_doc, "MSPointerMove", self.ontouchmove);
+          self.bind(_doc, "MSPointerMove", self.ontouchmove);
           self.bind(self.cursor, "MSGestureHold", function (e) {
             e.preventDefault();
           });
@@ -1672,7 +1672,7 @@
           self.bind(self.win, "touchstart", self.ontouchstart, false, true);
           self.bind(_doc, "touchend", self.ontouchend, false, true);
           self.bind(_doc, "touchcancel", self.ontouchend, false, true);
-          self.delegate(_doc, "touchmove", self.ontouchmove, false, true);
+          self.bind(_doc, "touchmove", self.ontouchmove, false, true);
         }

         if (opt.emulatetouch) {
glacios commented 3 years ago

By the way, error also fires in IE 10 and 11 regardless device has touchscreen or not

glacios commented 3 years ago

697