Selaa lähdekoodia

Remove Transition/Animation auto-detection and add TransitionRegister/AnimationRegister options.

Auto-detection causes that the css file must be on the same server. Remote hosting was impossible.
Jay Salvat 10 vuotta sitten
vanhempi
commit
eb2459d62e
4 muutettua tiedostoa jossa 78 lisäystä ja 92 poistoa
  1. 39 46
      dist/vegas.js
  2. 1 1
      dist/vegas.min.js
  3. 0 0
      dist/vegas.min.js.map
  4. 38 45
      src/vegas.js

+ 39 - 46
dist/vegas.js

@@ -1,6 +1,6 @@
 /*!-----------------------------------------------------------------------------
  * Vegas - Fullscreen Backgrounds and Slideshows.
- * v2.0.1 - built 2015-03-05
+ * v2.0.1 - built 2015-03-06
  * Licensed under the MIT License.
  * http://vegas.jaysalvat.com/
  * ----------------------------------------------------------------------------
@@ -29,8 +29,10 @@
         valign:             'center',
         transition:         'fade',
         transitionDuration: 1000,
+        transitionRegister: [],
         animation:          null,
         animationDuration:  'auto',
+        animationRegister:  [],
         init:  function () {},
         play:  function () {},
         pause: function () {},
@@ -67,8 +69,40 @@
         this.$overlay     = null;
         this.$slide       = null;
         this.timeout      = null;
-        this.transitions  = [];
-        this.animations   = [];
+
+        this.transitions = [
+            'fade', 'fade2',
+            'blur', 'blur2',
+            'flash', 'flash2',
+            'negative', 'negative2',
+            'burn', 'burn2',
+            'slideLeft', 'slideLeft2',
+            'slideRight', 'slideRight2',
+            'slideUp', 'slideUp2',
+            'slideDown', 'slideDown2',
+            'zoomIn', 'zoomIn2',
+            'zoomOut', 'zoomOut2',
+            'swirlLeft', 'swirlLeft2',
+            'swirlRight', 'swirlRight2'
+        ];
+
+        this.animations = [
+            'kenburns',
+            'kenburnsLeft', 'kenburnsRight',
+            'kenburnsUp', 'kenburnsUpLeft', 'kenburnsUpRight',
+            'kenburnsDown', 'kenburnsDownLeft', 'kenburnsDownRight'
+        ];
+
+        if (this.settings.transitionRegister instanceof Array === false) {
+            this.settings.transitionRegister = [ this.settings.transitionRegister ];
+        }
+
+        if (this.settings.animationRegister instanceof Array === false) {
+            this.settings.animationRegister = [ this.settings.animationRegister ];
+        }
+        
+        this.transitions = this.transitions.concat(this.settings.transitionRegister);
+        this.animations  = this.animations.concat(this.settings.animationRegister);
 
         this.support = {
             objectFit:  'objectFit'  in document.body.style,
@@ -76,37 +110,6 @@
             video:      $.vegas.isVideoCompatible()
         };
 
-        for (var i = 0; i < document.styleSheets.length; i++) {
-            var sheet = document.styleSheets[i],
-                rules;
-
-            try {
-                rules = (sheet.cssRules || sheet.rules);
-            } catch(e) {
-                continue;
-            }
-            
-            if (/vegas(\..*?)?(\.min)?\.css$/.test(sheet.href)) {
-                for (var j = 0; j < rules.length; j++) {
-                    var rule  = rules[j],
-                        matchTransition = /vegas\-transition\-([a-z0-9]*)/gi.exec(rule.selectorText),
-                        matchAnimation  = /vegas\-animation\-([a-z0-9]*)/gi.exec(rule.selectorText);
-                
-                    if (matchTransition && matchTransition[1]) {
-                        if (this.transitions.indexOf(matchTransition[1]) === -1) {
-                            this.transitions.push(matchTransition[1]);
-                        }
-                    }
-
-                    if (matchAnimation && matchAnimation[1]) {
-                        if (this.animations.indexOf(matchAnimation[1]) === -1) {
-                            this.animations.push(matchAnimation[1]);
-                        }
-                    }
-                }
-            }
-        }
-
         if (this.settings.shuffle === true) {
             this.shuffle();
         }
@@ -317,7 +320,7 @@
                 if (transition instanceof Array) {
                     transition = this._random(transition);
                 } else {
-                    transition = this._random(this.transitions);
+                    transition = this._random(this.animations);
                 }
             }
 
@@ -329,14 +332,6 @@
                 }
             }
 
-            if (transition && transition !== 'none' && this.transitions.indexOf(transition) < 0) {
-                console.error("Vegas: Transition " + transition + " doesn't exist.");
-            }
-
-            if (animation && animation !== 'none' && this.animations.indexOf(animation) < 0) {
-                console.error("Vegas: Animation " + animation + " doesn't exist.");
-            }
-
             if (transitionDuration === 'auto' || transitionDuration > delay) {
                 transitionDuration = delay;
             }
@@ -629,6 +624,4 @@
         return !/(Android|webOS|Phone|iPad|iPod|BlackBerry|Windows Phone)/i.test(navigator.userAgent);
     };
 
-})(typeof jQuery !== 'undefined' ? jQuery :
-   typeof Zepto  !== 'undefined' ? Zepto  : null
-);
+})(window.jQuery || window.Zepto);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 1
dist/vegas.min.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/vegas.min.js.map


+ 38 - 45
src/vegas.js

@@ -20,8 +20,10 @@
         valign:             'center',
         transition:         'fade',
         transitionDuration: 1000,
+        transitionRegister: [],
         animation:          null,
         animationDuration:  'auto',
+        animationRegister:  [],
         init:  function () {},
         play:  function () {},
         pause: function () {},
@@ -58,8 +60,40 @@
         this.$overlay     = null;
         this.$slide       = null;
         this.timeout      = null;
-        this.transitions  = [];
-        this.animations   = [];
+
+        this.transitions = [
+            'fade', 'fade2',
+            'blur', 'blur2',
+            'flash', 'flash2',
+            'negative', 'negative2',
+            'burn', 'burn2',
+            'slideLeft', 'slideLeft2',
+            'slideRight', 'slideRight2',
+            'slideUp', 'slideUp2',
+            'slideDown', 'slideDown2',
+            'zoomIn', 'zoomIn2',
+            'zoomOut', 'zoomOut2',
+            'swirlLeft', 'swirlLeft2',
+            'swirlRight', 'swirlRight2'
+        ];
+
+        this.animations = [
+            'kenburns',
+            'kenburnsLeft', 'kenburnsRight',
+            'kenburnsUp', 'kenburnsUpLeft', 'kenburnsUpRight',
+            'kenburnsDown', 'kenburnsDownLeft', 'kenburnsDownRight'
+        ];
+
+        if (this.settings.transitionRegister instanceof Array === false) {
+            this.settings.transitionRegister = [ this.settings.transitionRegister ];
+        }
+
+        if (this.settings.animationRegister instanceof Array === false) {
+            this.settings.animationRegister = [ this.settings.animationRegister ];
+        }
+        
+        this.transitions = this.transitions.concat(this.settings.transitionRegister);
+        this.animations  = this.animations.concat(this.settings.animationRegister);
 
         this.support = {
             objectFit:  'objectFit'  in document.body.style,
@@ -67,37 +101,6 @@
             video:      $.vegas.isVideoCompatible()
         };
 
-        for (var i = 0; i < document.styleSheets.length; i++) {
-            var sheet = document.styleSheets[i],
-                rules;
-
-            try {
-                rules = (sheet.cssRules || sheet.rules);
-            } catch(e) {
-                continue;
-            }
-            
-            if (/vegas(\..*?)?(\.min)?\.css$/.test(sheet.href)) {
-                for (var j = 0; j < rules.length; j++) {
-                    var rule  = rules[j],
-                        matchTransition = /vegas\-transition\-([a-z0-9]*)/gi.exec(rule.selectorText),
-                        matchAnimation  = /vegas\-animation\-([a-z0-9]*)/gi.exec(rule.selectorText);
-                
-                    if (matchTransition && matchTransition[1]) {
-                        if (this.transitions.indexOf(matchTransition[1]) === -1) {
-                            this.transitions.push(matchTransition[1]);
-                        }
-                    }
-
-                    if (matchAnimation && matchAnimation[1]) {
-                        if (this.animations.indexOf(matchAnimation[1]) === -1) {
-                            this.animations.push(matchAnimation[1]);
-                        }
-                    }
-                }
-            }
-        }
-
         if (this.settings.shuffle === true) {
             this.shuffle();
         }
@@ -308,7 +311,7 @@
                 if (transition instanceof Array) {
                     transition = this._random(transition);
                 } else {
-                    transition = this._random(this.transitions);
+                    transition = this._random(this.animations);
                 }
             }
 
@@ -320,14 +323,6 @@
                 }
             }
 
-            if (transition && transition !== 'none' && this.transitions.indexOf(transition) < 0) {
-                console.error("Vegas: Transition " + transition + " doesn't exist.");
-            }
-
-            if (animation && animation !== 'none' && this.animations.indexOf(animation) < 0) {
-                console.error("Vegas: Animation " + animation + " doesn't exist.");
-            }
-
             if (transitionDuration === 'auto' || transitionDuration > delay) {
                 transitionDuration = delay;
             }
@@ -620,6 +615,4 @@
         return !/(Android|webOS|Phone|iPad|iPod|BlackBerry|Windows Phone)/i.test(navigator.userAgent);
     };
 
-})(typeof jQuery !== 'undefined' ? jQuery :
-   typeof Zepto  !== 'undefined' ? Zepto  : null
-);
+})(window.jQuery || window.Zepto);

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä