Permalink
Browse files

Added destroy for multiple use.

  • Loading branch information...
1 parent 9586e3b commit 6f8e361794ec5116334ade1341a4f8390f5cf7e7 @ICKENICK ICKENICK committed Oct 10, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/swipeview.js
View
@@ -30,6 +30,8 @@ var SwipeView = (function(){
this.wrapper.style.overflow = 'hidden';
this.wrapper.style.position = 'relative';
+ this.masterPages = [];
+
div = document.createElement('div');
div.style.cssText = 'position:relative;top:0;height:100%;width:100%;-webkit-transition-duration:0;-webkit-transform:translate3d(0,0,0);-webkit-transition-timining-function:ease-out';
this.wrapper.appendChild(div);
@@ -225,6 +227,19 @@ var SwipeView = (function(){
imageEl.height = this.options.pages[newIndex].height;
}
}
+ },
+
+ destroy: function () {
+ // Remove the event listeners
+ window.removeEventListener(resizeEvent, this, false);
+ this.wrapper.removeEventListener(startEvent, this, false);
+ this.wrapper.removeEventListener(moveEvent, this, false);
+ this.wrapper.removeEventListener(endEvent, this, false);
+ this.slider.removeEventListener('webkitTransitionEnd', this, false);
+
+ if (!hasTouch) {
+ this.wrapper.removeEventListener('mouseout', this, false);
+ }
}
};

0 comments on commit 6f8e361

Please sign in to comment.