1/* 2 * transform: A jQuery cssHooks adding 2D/3D transform capabilities to $.fn.css() and $.fn.animate() 3 * 4 * Requirements: 5 * - jQuery 1.5.1+ 6 * - jquery.transition.js for animations 7 * - browser implementing W3C's CSS 2DTransforms for 2D tranform 8 * - browser implementing W3C's CSS 3DTransforms for 3D tranform 9 * 10 * latest version and complete README available on Github: 11 * https://github.com/louisremi/jquery.transform.js 12 * 13 * Copyright 2011 @louis_remi 14 * Licensed under the MIT license. 15 * 16 * This saved you an hour of work? 17 * Send me music http://www.amazon.co.uk/wishlist/HNTU0468LQON 18 * 19 */ 20(function( $, window, document ) { 21"use strict"; 22 23var div = document.createElement("div"), 24 divStyle = div.style, 25 prefixes = [ 26 "O", 27 "ms", 28 "Webkit", 29 "Moz" 30 ], 31 prefix, 32 i = prefixes.length, 33 properties = [ 34 "transform", 35 "transformOrigin", 36 "transformStyle", 37 "perspective", 38 "perspectiveOrigin", 39 "backfaceVisibility" 40 ], 41 property, 42 j = prefixes.length; 43 44// Find the right prefix 45while ( i-- ) { 46 if ( prefixes[i] + leadingUppercase( properties[0] ) in divStyle ) { 47 prefix = prefixes[i]; 48 continue; 49 } 50} 51 52// This browser is not compatible with transforms 53if ( !prefix ) { return; } 54 55// Build cssHooks for each property 56while ( j-- ) { 57 property = prefix + leadingUppercase( properties[j] ); 58 59 if ( property in divStyle ) { 60 61 // px isn't the default unit of this property 62 $.cssNumber[ properties[j] ] = true; 63 64 // populate cssProps 65 $.cssProps[ properties[j] ] = property; 66 67 // MozTranform requires a complete hook because "px" is required in translate 68 property === "MozTransform" && ($.cssHooks[ properties[j] ] = { 69 get: function( elem, computed ) { 70 return (computed ? 71 // remove "px" from the computed matrix 72 $.css( elem, property ).split("px").join(""): 73 elem.style[property] 74 ); 75 }, 76 set: function( elem, value ) { 77 // add "px" to matrices 78 /matrix\([^)p]*\)/.test(value) && ( 79 value = value.replace(/matrix((?:[^,]*,){4})([^,]*),([^)]*)/, "matrix$1$2px,$3px") 80 ); 81 elem.style[property] = value; 82 } 83 }); 84 85 } 86} 87 88function leadingUppercase( word ) { 89 return word.slice(0,1).toUpperCase() + word.slice(1); 90} 91 92})( jQuery, window, document );
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.