From 3410cf89be20eff36de056f92628702f904b9772 Mon Sep 17 00:00:00 2001 From: maoziliang Date: Sat, 1 Jun 2013 22:09:18 +0800 Subject: [PATCH] update the destroy method. unbind listeners by event namespace. This will be convenient for adding new event bind in the file. Do not worry about forgetting to unbind it. --- src/perfect-scrollbar.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index b1aae76..3a5128f 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -211,7 +211,7 @@ return true; }; - $this.mousewheel(function (e, delta, deltaX, deltaY) { + $this.bind('mousewheel.perfect-scroll', function (e, delta, deltaX, deltaY) { $this.scrollTop($this.scrollTop() - (deltaY * settings.wheelSpeed)); $this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed)); @@ -289,12 +289,8 @@ var destroy = function () { $scrollbarX.remove(); $scrollbarY.remove(); - $this.unbind('mousewheel'); - $this.unbind('touchstart.perfect-scroll'); - $this.unbind('touchmove.perfect-scroll'); - $this.unbind('touchend.perfect-scroll'); - $(window).unbind('mousemove.perfect-scroll'); - $(window).unbind('mouseup.perfect-scroll'); + $this.unbind('.perfect-scroll'); + $(window).unbind('.perfect-scroll'); $this.data('perfect-scrollbar', null); $this.data('perfect-scrollbar-update', null); $this.data('perfect-scrollbar-destroy', null);