1/* 2 * jQuery.translate3d.js v0.2 3 * 4 * Copyright (c) 2013 Richard Scarrott 5 * http://www.richardscarrott.co.uk 6 * 7 * Dual licensed under the MIT and GPL licenses: 8 * http://www.opensource.org/licenses/mit-license.php 9 * http://www.gnu.org/licenses/gpl.html 10 * 11 * // getter 12 * $(selector).css('translate3d'); // returns { x: val, y: val, z: val } 13 * 14 * // setter 15 * $(selector).css('translate3d', { x: val, y: val, z: val }); 16 * 17 * // support 18 * $.support.transform3d; // returns boolean 19 * 20 */ 21 22(function ($) { 23 24 // getSupportedProp mostly taken from http://api.jquery.com/jQuery.cssHooks/ 25 var getSupportedProp = function (prop) { 26 27 var vendorProp, 28 supportedProp, 29 capProp = prop.charAt(0).toUpperCase() + prop.slice(1), 30 prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'], 31 style = document.documentElement.style; 32 33 if (prop in style) { 34 supportedProp = prop; 35 } 36 else { 37 for (var i = 0; i < prefixes.length; i++) { 38 vendorProp = prefixes[i] + capProp; 39 if (vendorProp in style) { 40 supportedProp = vendorProp; 41 break; 42 } 43 } 44 } 45 46 div = null; 47 $.support[prop] = supportedProp; 48 return supportedProp; 49 }, 50 transform = getSupportedProp('transform'); 51 52 if ($.support.transform) { 53 $.cssHooks.translate3d = { 54 set: function(elem, obj) { 55 56 obj = $.extend({ 57 x: 0, 58 y: 0, 59 z: 0 60 }, obj); 61 62 // append px if unit not passed in 63 $.each(obj, function (prop, val) { 64 obj[prop] = typeof val === 'number' ? val + 'px' : val; 65 }); 66 67 elem.style[transform] = 'translate3d(' + obj.x + ', ' + obj.y + ', ' + obj.z + ')'; 68 }, 69 70 // properly regex out all three values... prob shouldn't convert to Int here incase the value was percentage etc. 71 get: function (elem) { 72 var value = elem.style[transform]; 73 if (value) { 74 value = value.split('(')[1].split(','); // a bit rubbish me thinks... 75 return { 76 x: parseInt(value[0], 10), 77 y: parseInt(value[1], 10), 78 z: parseInt(value[2].split(')')[0], 10) 79 }; 80 } 81 } 82 }; 83 } 84 85})(jQuery);
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.