00001 /* 00002 Copyright (c) 2004-2006, The Dojo Foundation 00003 All Rights Reserved. 00004 00005 Licensed under the Academic Free License version 2.1 or above OR the 00006 modified BSD license. For more information on Dojo licensing, see: 00007 00008 http://dojotoolkit.org/community/licensing.shtml 00009 */ 00010 00011 00012 00013 dojo.provide("dojo.lfx.extras"); 00014 dojo.require("dojo.lfx.html"); 00015 dojo.require("dojo.lfx.Animation"); 00016 dojo.lfx.html.fadeWipeIn = function (nodes, duration, easing, callback) { 00017 nodes = dojo.lfx.html._byId(nodes); 00018 var anim = dojo.lfx.combine(dojo.lfx.fadeIn(nodes, duration, easing), dojo.lfx.wipeIn(nodes, duration, easing)); 00019 if (callback) { 00020 anim.connect("onEnd", function () { 00021 callback(nodes, anim); 00022 }); 00023 } 00024 return anim; 00025 }; 00026 dojo.lfx.html.fadeWipeOut = function (nodes, duration, easing, callback) { 00027 nodes = dojo.lfx.html._byId(nodes); 00028 var anim = dojo.lfx.combine(dojo.lfx.fadeOut(nodes, duration, easing), dojo.lfx.wipeOut(nodes, duration, easing)); 00029 if (callback) { 00030 anim.connect("onEnd", function () { 00031 callback(nodes, anim); 00032 }); 00033 } 00034 return anim; 00035 }; 00036 dojo.lfx.html.scale = function (nodes, percentage, scaleContent, fromCenter, duration, easing, callback) { 00037 nodes = dojo.lfx.html._byId(nodes); 00038 var anims = []; 00039 dojo.lang.forEach(nodes, function (node) { 00040 var outer = dojo.html.getMarginBox(node); 00041 var actualPct = percentage / 100; 00042 var props = [{property:"width", start:outer.width, end:outer.width * actualPct}, {property:"height", start:outer.height, end:outer.height * actualPct}]; 00043 if (scaleContent) { 00044 var fontSize = dojo.html.getStyle(node, "font-size"); 00045 var fontSizeType = null; 00046 if (!fontSize) { 00047 fontSize = parseFloat("100%"); 00048 fontSizeType = "%"; 00049 } else { 00050 dojo.lang.some(["em", "px", "%"], function (item, index, arr) { 00051 if (fontSize.indexOf(item) > 0) { 00052 fontSize = parseFloat(fontSize); 00053 fontSizeType = item; 00054 return true; 00055 } 00056 }); 00057 } 00058 props.push({property:"font-size", start:fontSize, end:fontSize * actualPct, units:fontSizeType}); 00059 } 00060 if (fromCenter) { 00061 var positioning = dojo.html.getStyle(node, "position"); 00062 var originalTop = node.offsetTop; 00063 var originalLeft = node.offsetLeft; 00064 var endTop = ((outer.height * actualPct) - outer.height) / 2; 00065 var endLeft = ((outer.width * actualPct) - outer.width) / 2; 00066 props.push({property:"top", start:originalTop, end:(positioning == "absolute" ? originalTop - endTop : (-1 * endTop))}); 00067 props.push({property:"left", start:originalLeft, end:(positioning == "absolute" ? originalLeft - endLeft : (-1 * endLeft))}); 00068 } 00069 var anim = dojo.lfx.propertyAnimation(node, props, duration, easing); 00070 if (callback) { 00071 anim.connect("onEnd", function () { 00072 callback(node, anim); 00073 }); 00074 } 00075 anims.push(anim); 00076 }); 00077 return dojo.lfx.combine(anims); 00078 }; 00079 dojo.lang.mixin(dojo.lfx, dojo.lfx.html); 00080
For more help developing with SiT! see http://sitracker.org/wiki/DevelopmentHowTo