Browse Source

Merge pull request #814 from tkacperek/fix762

Undelegate event handlers when instance is removed
Inuyaksa 3 years ago
parent
commit
289597a5ea
1 changed files with 8 additions and 0 deletions
  1. 8 0
      jquery.nicescroll.js

+ 8 - 0
jquery.nicescroll.js

@@ -2630,6 +2630,14 @@
       if (self.cursortimeout) clearTimeout(self.cursortimeout);
       for (var n in self.delaylist) if (self.delaylist[n]) clearAnimationFrame(self.delaylist[n].h);
       self.doZoomOut();
+
+      if (cap.hasw3ctouch) { //IE11+
+        self.undelegate(_doc, "pointermove", self.ontouchmove);
+      } else if (cap.hasmstouch) { //IE10
+        self.undelegate(_doc, "MSPointerMove", self.ontouchmove);
+      } else if (cap.cantouch) { // smartphones/touch devices
+        self.undelegate(_doc, "touchmove", self.ontouchmove, false, true);
+      }
       self.unbindAll();
 
       if (cap.isie9) self.win[0].detachEvent("onpropertychange", self.onAttributeChange); //IE9 DOMAttrModified bug