Переглянути джерело

Refresh the slide total when options are changed and better timer management

Jay Salvat 10 роки тому
батько
коміт
1a2dbb39d9
4 змінених файлів з 20 додано та 12 видалено
  1. 10 6
      dist/vegas.js
  2. 0 0
      dist/vegas.min.js
  3. 0 0
      dist/vegas.min.js.map
  4. 10 6
      src/vegas.js

+ 10 - 6
dist/vegas.js

@@ -99,7 +99,6 @@
                 timer     = this.settings.timer,
                 overlay   = this.settings.overlay,
                 preload   = this.settings.preload,
-                position  = this.$elmt.css('position'),
                 img,
                 i;
 
@@ -165,10 +164,7 @@
         _slideShow: function () {
             var self = this;
 
-            if (this.paused || this.noshow) {
-                clearTimeout(this.timeout);
-            } else {
-                clearTimeout(this.timeout);
+            if (this.total > 1 && !this.paused && !this.noshow) {
                 this.timeout = setTimeout(function () {
                     self.next();
                 }, this._options('delay')); 
@@ -180,7 +176,7 @@
 
             clearTimeout(this.timeout);
 
-            if (!this.$timer || this.paused || this.noshow) {
+            if (!this.$timer) {
                 return;
             }
 
@@ -189,6 +185,10 @@
                     .find('div')
                         .css('transition-duration', '0ms');
 
+            if (this.paused || this.noshow) {
+                return;
+            }
+
             if (state) {
                 setTimeout(function () {
                    self.$timer
@@ -468,6 +468,10 @@
             } else {
                 return this.settings;
             }
+
+            // In case slides have changed
+            this.total  = this.settings.slides.length;
+            this.noshow = this.total < 2;
         }
     };
 

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
dist/vegas.min.js


Різницю між файлами не показано, бо вона завелика
+ 0 - 0
dist/vegas.min.js.map


+ 10 - 6
src/vegas.js

@@ -90,7 +90,6 @@
                 timer     = this.settings.timer,
                 overlay   = this.settings.overlay,
                 preload   = this.settings.preload,
-                position  = this.$elmt.css('position'),
                 img,
                 i;
 
@@ -156,10 +155,7 @@
         _slideShow: function () {
             var self = this;
 
-            if (this.paused || this.noshow) {
-                clearTimeout(this.timeout);
-            } else {
-                clearTimeout(this.timeout);
+            if (this.total > 1 && !this.paused && !this.noshow) {
                 this.timeout = setTimeout(function () {
                     self.next();
                 }, this._options('delay')); 
@@ -171,7 +167,7 @@
 
             clearTimeout(this.timeout);
 
-            if (!this.$timer || this.paused || this.noshow) {
+            if (!this.$timer) {
                 return;
             }
 
@@ -180,6 +176,10 @@
                     .find('div')
                         .css('transition-duration', '0ms');
 
+            if (this.paused || this.noshow) {
+                return;
+            }
+
             if (state) {
                 setTimeout(function () {
                    self.$timer
@@ -459,6 +459,10 @@
             } else {
                 return this.settings;
             }
+
+            // In case slides have changed
+            this.total  = this.settings.slides.length;
+            this.noshow = this.total < 2;
         }
     };
 

Деякі файли не було показано, через те що забагато файлів було змінено