فهرست منبع

first memory leak fix

Admin 12 سال پیش
والد
کامیت
8fcf816095
3فایلهای تغییر یافته به همراه24 افزوده شده و 36 حذف شده
  1. 15 11
      demo/index.html
  2. 0 15
      demo/js/jquery.min.js
  3. 9 10
      jquery.nicescroll.js

+ 15 - 11
demo/index.html

@@ -44,21 +44,25 @@
 </style>
 
 <script src="js/jquery.min.js"></script>
-<script src="js/jquery.nicescroll.min.js"></script>
+<script src="../jquery.nicescroll.js"></script>
 
 <script>
   $(document).ready(function() {
-  
-	var nice = $("html").niceScroll();  // The document page (body)
-	
-	$("#div1").html($("#div1").html()+' '+nice.version);
-    
-    $("#boxscroll").niceScroll({cursorborder:"",cursorcolor:"#00F",boxzoom:true}); // First scrollable DIV
+  var nice = $("html").niceScroll();
+  $("#div1").html($("#div1").html()+' '+nice.version);
+
+  var toggleScroll = function () {
+    if (nice) {
+      nice.remove();
+      nice = null;
+    } else {
+      nice = $("html").niceScroll();  // The document page (body)
+    }
 
-    $("#boxscroll2").niceScroll("#contentscroll2",{cursorcolor:"#F00",cursoropacitymax:0.7,boxzoom:true,touchbehavior:true});  // Second scrollable DIV
-    $("#boxframe").niceScroll("#boxscroll3",{cursorcolor:"#0F0",cursoropacitymax:0.7,boxzoom:true,touchbehavior:true});  // This is an IFrame (iPad compatible)
+  };
+
+  $('button').on('click',toggleScroll);
 	
-    $("#boxscroll4").niceScroll("#boxscroll4 .wrapper",{boxzoom:true});  // hw acceleration enabled when using wrapper
     
   });
 </script>
@@ -68,7 +72,7 @@
 </head>
 
 <body>
-
+<button>Toggle scroll</button>
 <div id="div1"><strong>NiceScroll version:</strong></div>
 
 <div id="boxscroll">

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 15
demo/js/jquery.min.js


+ 9 - 10
jquery.nicescroll.js

@@ -2101,6 +2101,7 @@
     };
     
     this.remove = function() {
+
       self.stop();
       if (self.cursortimeout) clearTimeout(self.cursortimeout);
       self.doZoomOut();
@@ -2110,23 +2111,18 @@
       self.events = [];
       if (self.cursor) {
         self.cursor.remove();
-        self.cursor = null;
       }
       if (self.cursorh) {
         self.cursorh.remove();
-        self.cursorh = null;
       }
       if (self.rail) {
         self.rail.remove();
-        self.rail = null;
       }
       if (self.railh) {
         self.railh.remove();
-        self.railh = null;
       }
       if (self.zoom) {
         self.zoom.remove();
-        self.zoom = null;
       }
       for(var a=0;a<self.saved.css.length;a++) {
         var d=self.saved.css[a];
@@ -2134,11 +2130,12 @@
       }
       self.saved = false;      
       self.me.data('__nicescroll',''); //erase all traces
-	  self.me = null;
-	  self.doc = null;
-	  self.docscroll = null;
-	  self.win = null;
-      return self;
+  	  for (var i in self) {
+        self[i] = null;
+        delete self[i];
+      }
+      delete this;
+      
     };
     
     this.scrollstart = function(fn) {
@@ -3121,7 +3118,9 @@
         wrapper = false;        
       }
     }
+    // TODO clear this array
     var ret = new NiceScrollArray();
+
     if (typeof opt=="undefined") opt = {};
     
     if (wrapper||false) {      

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است