Changeset 3855
- Timestamp:
- 11/19/07 16:05:40 (1 year ago)
- Location:
- trunk/fx/experimental
- Files:
-
- 13 modified
-
fx.blind.js (modified) (2 diffs)
-
fx.drop.js (modified) (2 diffs)
-
fx.fold.js (modified) (2 diffs)
-
fx.highlight.js (modified) (3 diffs)
-
fx.js (modified) (4 diffs)
-
fx.pulsate.js (modified) (3 diffs)
-
fx.slide.js (modified) (3 diffs)
-
tests/blind.html (modified) (1 diff)
-
tests/drop.html (modified) (2 diffs)
-
tests/fold.html (modified) (1 diff)
-
tests/highlight.html (modified) (1 diff)
-
tests/pulsate.html (modified) (1 diff)
-
tests/slide.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fx/experimental/fx.blind.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx.blind = function(o) {3 $.ec.blind = function(o) { 4 4 5 5 this.each(function() { … … 14 14 15 15 // Set options 16 var direction = o.options.direction || "vertical";17 var ref = (direction == "vertical") ? "height" : "width";18 var distance = (direction == "vertical") ? wrapper.height() : wrapper.width();16 var direction = o.options.direction || 'vertical'; 17 var ref = (direction == 'vertical') ? 'height' : 'width'; 18 var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); 19 19 20 20 // Adjust 21 if(o.method == "show") wrapper.css(ref, 0);21 if(o.method == 'show') wrapper.css(ref, 0); 22 22 el.show(); 23 23 24 24 // Animation 25 25 var animation = {}; 26 animation[ref] = o.method == "show"? distance : 0;26 animation[ref] = o.method == 'show' ? distance : 0; 27 27 28 28 // Animate 29 29 wrapper.animate(animation, o.speed, o.options.easing, function() { 30 if(o.method != "show") el.hide(); //if we want to hide the element, set display to none after the animation31 wrapper.replaceWith(el); // remove the wrapper32 if(o.callback) callback.apply(this, arguments); //And optionally apply the callback30 if(o.method != 'show') el.hide(); 31 wrapper.replaceWith(el); 32 if(o.callback) callback.apply(this, arguments); 33 33 }); 34 34 -
trunk/fx/experimental/fx.drop.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx.drop = function(o) {3 $.ec.drop = function(o) { 4 4 5 5 this.each(function() { … … 7 7 // Create element 8 8 var el = $(this); 9 $.fx.relativize(el); 10 $.fx.save(el, ["top","left","opacity"]); 9 var props = ['position','opacity']; 11 10 12 11 // Set options 13 var direction = o.options.direction || "left"; 14 var ref = (direction == "up" || direction == "down") ? "top" : "left"; 15 var motion = (direction == "up" || direction == "left") ? "pos" : "neg"; 16 var distance = o.options.distance || ref == "top" ? (el.height() / 2) : (el.width() / 2); 17 var shift = !parseInt(el.css(ref)) ? 0 : parseInt(el.css(ref)); // Need this for IE 12 var direction = o.options.direction || 'left'; 13 var s = $.ec.findSides(el), ref = { left: s[0], right: s[0], up: s[1], down: s[1] }; 14 props.push(ref[direction]); // Add side to props 15 var motion = (ref[direction] == 'top' || ref[direction] == 'left') ? 'pos' : 'neg'; 16 var distance = o.options.distance || (ref == 'top' ? (el.height() / 2) : (el.width() / 2)); 17 var shift = parseInt(el.css(ref[direction])) || 0; 18 18 19 19 // Adjust 20 if (o.method == "show") el.css('opacity', 0).css(ref, shift + (motion == "pos" ? -distance : distance)); 20 $.ec.save(el, props); 21 el.makeRelative(); 22 if (o.method == 'show') el.css('opacity', 0).css(ref[direction], shift + (motion == 'pos' ? -distance : distance)); 21 23 el.show(); 22 24 23 25 // Animation 24 26 var animation = {}; 25 animation['opacity'] = o.method == "show"? 1 : 0;26 animation[ref ] = (o.method == "show" ? (motion == "pos" ? '+=' : '-=') : (motion == "pos"? '-=' : '+=')) + distance;27 animation['opacity'] = o.method == 'show' ? 1 : 0; 28 animation[ref[direction]] = (o.method == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; 27 29 28 30 // Animate 29 el.animate(animation, o.speed, o.options.easing, function() { //Animate30 if(o.method != "show") el.hide();31 $. fx.restore(el, ["left","top","opacity"]);31 el.animate(animation, o.speed, o.options.easing, function() { 32 if(o.method != 'show') el.hide(); 33 $.ec.restore(el, props); 32 34 if(o.callback) callback.apply(this, arguments); 33 35 }); -
trunk/fx/experimental/fx.fold.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx.fold = function(o) {3 $.ec.fold = function(o) { 4 4 5 5 this.each(function() { … … 14 14 15 15 // Set options 16 var direction = o.options.direction || "vertical"; 17 var ref = (o.method == "show") ? ["width", "height"] : ["height", "width"]; 16 var ref = (o.method == 'show') ? ['width', 'height'] : ['height', 'width']; 18 17 var size = o.options.size || 15; 19 var distance = (o.method == "show") ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];18 var distance = (o.method == 'show') ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; 20 19 21 20 // Adjust 22 if(o.method == "show") wrapper.css({height: size, width: 0});21 if(o.method == 'show') wrapper.css({height: size, width: 0}); 23 22 el.show(); 24 23 25 24 // Animation 26 var animation1 = {}; animation1[ref[0]] = o.method == "show"? distance[0] : size;27 var animation2 = {}; animation2[ref[1]] = o.method == "show"? distance[1] : 0;25 var animation1 = {}; animation1[ref[0]] = o.method == 'show' ? distance[0] : size; 26 var animation2 = {}; animation2[ref[1]] = o.method == 'show' ? distance[1] : 0; 28 27 29 // Animate 28 // Animate & Restore 30 29 wrapper.animate(animation1, o.speed, o.options.easing) 31 30 .animate(animation2, o.speed, o.options.easing, function() { 32 if(o.method != "show") el.hide(); //if we want to hide the element, set display to none after the animation33 wrapper.replaceWith(el); // remove the wrapper34 if(o.callback) callback.apply(this, arguments); //And optionally apply the callback31 if(o.method != 'show') el.hide(); 32 wrapper.replaceWith(el); 33 if(o.callback) callback.apply(this, arguments); 35 34 }); 36 35 -
trunk/fx/experimental/fx.highlight.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx.highlight = function(o) {3 $.ec.highlight = function(o) { 4 4 5 5 this.each(function() { … … 7 7 // Create element 8 8 var el = $(this); 9 $.fx.save(el, ["backgroundImage","backgroundColor","opacity"]);9 var props = ['backgroundImage','backgroundColor','opacity']; 10 10 11 11 // Set options 12 12 var color = o.options.color || "#ffff99" 13 13 14 // Adjust 15 el.css({backgroundImage: 'none', backgroundColor: color}) 14 // Adjust & Save 15 $.ec.save(el, props); 16 el.css({backgroundImage: 'none', backgroundColor: color}); 16 17 el.show(); 17 18 18 19 // Animation 19 20 var animation = {}; 20 animation['backgroundColor'] = $.data(this, " fx.storage.backgroundColor");21 animation['backgroundColor'] = $.data(this, "ec.storage.backgroundColor"); 21 22 if (o.method == "hide") animation['opacity'] = 0; 22 23 … … 24 25 el.animate(animation, o.speed, o.options.easing, function() { //Animate 25 26 if(o.method == "hide") el.hide(); 26 $. fx.restore(el, ["backgroundImage","backgroundColor","opacity"]);27 $.ec.restore(el, props); 27 28 if(o.callback) callback.apply(this, arguments); 28 29 }); -
trunk/fx/experimental/fx.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx = $.fx || {}; //Add the 'fx' scope3 $.ec = $.ec || {}; //Add the 'ec' scope 4 4 5 /* 6 * Public methods (jQuery FX scope) 7 */ 8 9 $.extend($.fx, { 10 relativize: function(el) { 11 if(!el.css("position") || !el.css("position").match(/fixed|absolute|relative/)) el.css("position", "relative"); //Relativize 12 }, 5 $.extend($.ec, { 13 6 save: function(el, set) { 14 7 for(var i=0;i<set.length;i++) { 15 if(set[i] !== null) $.data(el[0], " fx.storage."+set[i], el.css(set[i]));8 if(set[i] !== null) $.data(el[0], "ec.storage."+set[i], el.css(set[i])); 16 9 } 17 10 }, … … 19 12 if(ret) var obj = {}; 20 13 for(var i=0;i<set.length;i++) { 21 if(ret) obj[set[i]] = $.data(el[0], " fx.storage."+set[i]);22 if(set[i] !== null && !ret) el.css(set[i], $.data(el[0], " fx.storage."+set[i]));14 if(ret) obj[set[i]] = $.data(el[0], "ec.storage."+set[i]); 15 if(set[i] !== null && !ret) el.css(set[i], $.data(el[0], "ec.storage."+set[i])); 23 16 } 24 17 if(ret) return obj; 25 18 }, 19 findSides: function(el) { //Very nifty function (especially for IE!) 20 return [ !!parseInt(el.css("left")) ? "left" : "right", !!parseInt(el.css("top")) ? "top" : "bottom" ]; 21 }, 22 setTransition: function(el, list, factor, val) { 23 val = val || {}; 24 $.each(list,function(i, x){ 25 unit = el.cssUnit(x); 26 if (unit[0] > 0) val[x] = unit[0] * factor + unit[1]; 27 }); 28 return val; 29 }, 26 30 animateClass: function(value, duration, easing, callback) { 27 31 … … 61 65 } 62 66 }); 63 67 64 68 //Extend the methods of jQuery 65 69 $.fn.extend({ 66 //effect: function(fx,o) { if($.fx[fx]) this.each(function() { $.fx[fx].apply(this, [o]); }); }, //This just forwards single used effects 67 effect: function(fx,o,speed,callback) { if($.fx[fx]) $.fx[fx].apply(this, [{method: fx, options: o, speed: speed, callback: callback}])}, 70 //Save old methods 68 71 _show: $.fn.show, 69 72 _hide: $.fn.hide, … … 72 75 _removeClass: $.fn.removeClass, 73 76 _toggleClass: $.fn.toggleClass, 77 // New ec methods 78 effect: function(fx,o,speed,callback) { 79 if($.ec[fx]) $.ec[fx].apply(this, [{method: fx, options: o, speed: speed, callback: callback}]) 80 }, 74 81 show: function(obj,speed,callback){ 75 return typeof obj == 'string' || typeof obj == 'undefined' ? this._show(obj, speed) : $. fx[obj.method].apply(this, [{method: 'show', options: obj, duration: speed, callback: callback }]);82 return typeof obj == 'string' || typeof obj == 'undefined' ? this._show(obj, speed) : $.ec[obj.method].apply(this, [{method: 'show', options: obj, duration: speed, callback: callback }]); 76 83 }, 77 84 hide: function(obj,speed,callback){ 78 return typeof obj == 'string' || typeof obj == 'undefined' ? this._hide(obj, speed) : $. fx[obj.method].apply(this, [{method: 'hide', options: obj, duration: speed, callback: callback }]);85 return typeof obj == 'string' || typeof obj == 'undefined' ? this._hide(obj, speed) : $.ec[obj.method].apply(this, [{method: 'hide', options: obj, duration: speed, callback: callback }]); 79 86 }, 80 87 toggle: function(obj,speed,callback){ 81 return jQuery(this).is(":hidden") ? this.show(obj,speed,callback) : this.hide(obj,speed,callback)88 return $(this).is(':hidden') ? this.show(obj,speed,callback) : this.hide(obj,speed,callback) 82 89 }, 83 90 addClass: function(classNames,speed,easing,callback) { 84 return speed ? $. fx.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);91 return speed ? $.ec.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); 85 92 }, 86 93 removeClass: function(classNames,speed,easing,callback) { 87 return speed ? $. fx.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);94 return speed ? $.ec.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); 88 95 }, 89 96 toggleClass: function(classNames,speed,easing,callback) { 90 return speed ? $. fx.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames);97 return speed ? $.ec.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames); 91 98 }, 92 99 morph: function(remove,add,speed,easing,callback) { 93 return $. fx.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);100 return $.ec.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); 94 101 }, 95 switchClass: function() { this.morph.apply(this, arguments); }, 102 switchClass: function() { 103 this.morph.apply(this, arguments); 104 }, 105 // helper functions 106 makeRelative: function() { //Relativize 107 var pos = this.css('position'); 108 if (!pos || pos == 'static') { 109 this.css('position', 'relative'); 110 if (window.opera) { 111 element.style.top = 0; 112 element.style.left = 0; 113 }; 114 }; 115 }, 96 116 cssUnit: function(key) { 97 117 var style = this.css(key), val = []; -
trunk/fx/experimental/fx.pulsate.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx.pulsate = function(o) {3 $.ec.pulsate = function(o) { 4 4 5 5 this.each(function() { … … 12 12 13 13 // Adjust 14 if (jQuery(el).is( ":hidden")) {14 if (jQuery(el).is(':hidden')) { 15 15 el.fadeIn(o.speed, o.options.easing); 16 16 times--; … … 21 21 el.fadeOut(o.speed, o.options.easing).fadeIn(o.speed, o.options.easing); 22 22 }; 23 if (o.method == "hide") el.fadeOut(o.speed, o.options.easing);23 if (o.method == 'hide') el.fadeOut(o.speed, o.options.easing); 24 24 if(o.callback) callback.apply(this, arguments); 25 25 }); -
trunk/fx/experimental/fx.slide.js
r3838 r3855 1 1 (function($) { 2 2 3 $. fx.slide = function(o) {3 $.ec.slide = function(o) { 4 4 5 5 this.each(function() { … … 7 7 // Create element 8 8 var el = $(this); 9 $.fx.save(el, ["marginTop","marginLeft"]);9 var props = []; 10 10 11 11 // Create a wrapper … … 15 15 16 16 // Set options 17 var direction = o.options.direction || "left"; 18 var ref = (direction == "up" || direction == "down") ? "marginTop" : "marginLeft"; 19 var motion = (direction == "down" || direction == "right") ? "pos" : "neg"; 20 var distance = distance || ref == "marginTop" ? wrapper.height() : wrapper.width(); 21 var shift = !parseInt(el.css(ref)) ? 0 : parseInt(el.css(ref)); // Need this for IE 17 var direction = o.options.direction || 'left'; 18 var ref = (direction == 'up' || direction == 'down') ? 'marginTop' : 'marginLeft'; 19 props.push(ref); 20 var motion = (direction == 'down' || direction == 'right') ? 'pos' : 'neg'; 21 var distance = distance || ref == 'marginTop' ? wrapper.height() : wrapper.width(); 22 var shift = parseInt(el.css(ref)) || 0; 22 23 23 24 // Adjust 24 if (o.method == "show") el.css(ref, shift + (motion == "pos" ? distance : -distance)); 25 $.ec.save(el, props); 26 if (o.method == 'show') el.css(ref, shift + (motion == 'pos' ? distance : -distance)); 25 27 el.show(); 26 28 27 29 // Animation 28 30 var animation = {}; 29 animation[ref] = (o.method == "show" ? (motion == "pos" ? '-=' : '+=') : (motion == "pos"? '+=' : '-=')) + distance;31 animation[ref] = (o.method == 'show' ? (motion == 'pos' ? '-=' : '+=') : (motion == 'pos' ? '+=' : '-=')) + distance; 30 32 31 33 // Animate 32 34 el.animate(animation, o.speed, o.options.easing, function() { //Animate 33 if(o.method != "show") el.hide();34 $. fx.restore(el, ["marginTop","marginLeft"]);35 if(o.method != 'show') el.hide(); 36 $.ec.restore(el, props); 35 37 wrapper.replaceWith(el); 36 38 if(o.callback) callback.apply(this, arguments); -
trunk/fx/experimental/tests/blind.html
r3838 r3855 28 28 .controls div {padding:10px;clear:both;} 29 29 .text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 30 #container {height:420px; width:510px; margin:0 auto; text-align:center;}31 #fx {width:500px;background:#efefef;border:5px solid #aaa; }30 #container {height:420px; width:510px; margin:0 auto;} 31 #fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;} 32 32 </style> 33 33 </head> -
trunk/fx/experimental/tests/drop.html
r3838 r3855 12 12 <script type="text/javascript" src="../../../jquery/src/fx.js"></script> 13 13 <script type="text/javascript" src="../../../jquery/src/offset.js"></script> 14 <script type="text/javascript" src="../../../plugins/dimensions/jquery.dimensions.js"></script> 14 15 15 16 <script type="text/javascript" src="../fx.js"></script> … … 27 28 .controls div {padding:10px;clear:both;} 28 29 .text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 29 #container {height:420px; width:510px; margin:0 auto; text-align:center;}30 #fx {width:500px;background:#efefef;border:5px solid #aaa; }30 #container {height:420px; width:510px; margin:0 auto;} 31 #fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;} 31 32 </style> 32 33 </head> -
trunk/fx/experimental/tests/fold.html
r3838 r3855 28 28 .controls div {padding:10px;clear:both;} 29 29 .text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 30 #container {height:420px; width:510px; margin:0 auto; text-align:center;}31 #fx {width:500px;background:#efefef;border:5px solid #aaa; }30 #container {height:420px; width:510px; margin:0 auto;} 31 #fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;} 32 32 </style> 33 33 </head> -
trunk/fx/experimental/tests/highlight.html
r3838 r3855 28 28 .controls div {padding:10px;clear:both;} 29 29 .text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 30 #container {height:420px; width:510px; margin:0 auto; text-align:center;}31 #fx {width:500px;background:#efefef;border:5px solid #aaa; }30 #container {height:420px; width:510px; margin:0 auto;} 31 #fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;} 32 32 </style> 33 33 </head> -
trunk/fx/experimental/tests/pulsate.html
r3838 r3855 27 27 .controls div {padding:10px;clear:both;} 28 28 .text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 29 #container {height:420px; width:510px; margin:0 auto; text-align:center;}30 #fx {width:500px;background:#efefef;border:5px solid #aaa; }29 #container {height:420px; width:510px; margin:0 auto;} 30 #fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;} 31 31 </style> 32 32 </head> -
trunk/fx/experimental/tests/slide.html
r3838 r3855 28 28 .controls div {padding:10px;clear:both;} 29 29 .text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 30 #container {height:420px; width:510px; margin:0 auto; text-align:center;}31 #fx {width:500px;background:#efefef;border:5px solid #aaa; }30 #container {height:420px; width:510px; margin:0 auto;} 31 #fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;} 32 32 </style> 33 33 </head>
