1/* 2* CSSPlugin 3* Visit http://createjs.com/ for documentation, updates and examples. 4* 5* Copyright (c) 2010 gskinner.com, inc. 6* 7* Permission is hereby granted, free of charge, to any person 8* obtaining a copy of this software and associated documentation 9* files (the "Software"), to deal in the Software without 10* restriction, including without limitation the rights to use, 11* copy, modify, merge, publish, distribute, sublicense, and/or sell 12* copies of the Software, and to permit persons to whom the 13* Software is furnished to do so, subject to the following 14* conditions: 15* 16* The above copyright notice and this permission notice shall be 17* included in all copies or substantial portions of the Software. 18* 19* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 21* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26* OTHER DEALINGS IN THE SOFTWARE. 27*/ 28 29/** 30* @module TweenJS 31*/ 32 33// namespace: 34this.createjs = this.createjs||{}; 35 36(function() { 37 "use strict"; 38/** 39 * A TweenJS plugin for working with numeric CSS string properties (ex. top, left). To use simply install after 40 * TweenJS has loaded: 41 * 42 * createjs.CSSPlugin.install(); 43 * 44 * You can adjust the CSS properties it will work with by modifying the <code>cssSuffixMap</code> property. Currently, 45 * the top, left, bottom, right, width, height have a "px" suffix appended. 46 * 47 * Please note that the CSS Plugin is not included in the TweenJS minified file. 48 * @class CSSPlugin 49 * @constructor 50 **/ 51var CSSPlugin = function() { 52 throw("CSSPlugin cannot be instantiated.") 53} 54 55// static interface: 56 /** 57 * Defines the default suffix map for CSS tweens. This can be overridden on a per tween basis by specifying a 58 * cssSuffixMap value for the individual tween. The object maps CSS property names to the suffix to use when 59 * reading or setting those properties. For example a map in the form {top:"px"} specifies that when tweening 60 * the "top" CSS property, it should use the "px" suffix (ex. target.style.top = "20.5px"). This only applies 61 * to tweens with the "css" config property set to true. 62 * @property cssSuffixMap 63 * @type Object 64 * @static 65 **/ 66 CSSPlugin.cssSuffixMap = {top:"px",left:"px",bottom:"px",right:"px",width:"px",height:"px",opacity:""}; 67 68 /** 69 * @property priority 70 * @protected 71 * @static 72 **/ 73 CSSPlugin.priority = -100; // very low priority, should run last 74 75 /** 76 * Installs this plugin for use with TweenJS. Call this once after TweenJS is loaded to enable this plugin. 77 * @method install 78 * @static 79 **/ 80 CSSPlugin.install = function() { 81 var arr = [], map = CSSPlugin.cssSuffixMap; 82 for (var n in map) { arr.push(n); } 83 createjs.Tween.installPlugin(CSSPlugin, arr); 84 } 85 86 87 /** 88 * @method init 89 * @protected 90 * @static 91 **/ 92 CSSPlugin.init = function(tween, prop, value) { 93 var sfx0,sfx1,style,map = CSSPlugin.cssSuffixMap; 94 if ((sfx0 = map[prop]) == null || !(style = tween.target.style)) { return value; } 95 var str = style[prop]; 96 if (!str) { return 0; } // no style set. 97 var i = str.length-sfx0.length; 98 if ((sfx1 = str.substr(i)) != sfx0) { 99 throw("CSSPlugin Error: Suffixes do not match. ("+sfx0+":"+sfx1+")"); 100 } else { 101 return parseInt(str.substr(0,i)); 102 } 103 } 104 105 /** 106 * @method step 107 * @protected 108 * @static 109 **/ 110 CSSPlugin.step = function(tween, prop, startValue, endValue, injectProps) { 111 // unused 112 } 113 114 115 /** 116 * @method tween 117 * @protected 118 * @static 119 **/ 120 CSSPlugin.tween = function(tween, prop, value, startValues, endValues, ratio, wait, end) { 121 var style,map = CSSPlugin.cssSuffixMap; 122 if (map[prop] == null || !(style = tween.target.style)) { return value; } 123 style[prop] = value+map[prop]; 124 return createjs.Tween.IGNORE; 125 } 126 127// public properties: 128 129// private properties: 130 131// constructor: 132 133// public methods: 134 135 136// private methods: 137 138createjs.CSSPlugin = CSSPlugin; 139}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.