Ver código fonte

Fix the everlasting slide repeat when video is looped

Jay Salvat 10 anos atrás
pai
commit
98725221a8
1 arquivos alterados com 11 adições e 1 exclusões
  1. 11 1
      src/vegas.js

+ 11 - 1
src/vegas.js

@@ -157,6 +157,7 @@
             if (this.paused || this.noshow) {
                 clearTimeout(this.timeout);
             } else {
+                clearTimeout(this.timeout);
                 this.timeout = setTimeout(function () {
                     self.next();
                 }, this._options('delay')); 
@@ -331,8 +332,17 @@
             }
 
             if (video) {
+                // oncanplay is triggered every time when loop=true
+                // so let's start the slide only once
+                var played = false; 
+
                 video.play();
-                video.oncanplay = go;
+                video.oncanplay = function () {
+                    if (!played) {
+                        played = true;
+                        go();
+                    }
+                };
             } else {
                 img.onload = go;
             }