| OLD | NEW |
| (Empty) | |
| 1 define([ 'util/ensureCallback', 'features', 'Modernizr', 'sprites/renderers/DomC
ontext', 'util/create', 'sprites/container', 'util/quickPromise' ], function (en
sureCallback, features, Modernizr, DomContext, create, container, quickPromise)
{ |
| 2 function RenderContext(sourceData, frameData) { |
| 3 if (!Modernizr.csstransforms3d) { |
| 4 return; |
| 5 } |
| 6 |
| 7 this.loadPromise = quickPromise(); |
| 8 DomContext.call(this, sourceData, frameData, this.loadPromise.resolve); |
| 9 |
| 10 this.elements.forEach(function (frameElements) { |
| 11 frameElements.forEach(function (element) { |
| 12 element.style[features.transformOriginStyleProperty] = '0 0'; |
| 13 }); |
| 14 }); |
| 15 |
| 16 this.transformData = frameData.map(function (objectTransforms) { |
| 17 return objectTransforms.map(function (t) { |
| 18 return t.cssTransform3d; |
| 19 }); |
| 20 }); |
| 21 |
| 22 this.containerElement = container(); |
| 23 } |
| 24 |
| 25 RenderContext.prototype = create(DomContext.prototype); |
| 26 |
| 27 RenderContext.prototype.load = function load(callback) { |
| 28 callback = ensureCallback(callback); |
| 29 |
| 30 if (!Modernizr.csstransforms3d) { |
| 31 callback(new Error('Not supported')); |
| 32 return; |
| 33 } |
| 34 |
| 35 document.body.appendChild(this.containerElement); |
| 36 |
| 37 this.loadPromise.then(function () { |
| 38 callback(null); |
| 39 }); |
| 40 }; |
| 41 |
| 42 RenderContext.prototype.unload = function unload() { |
| 43 this.containerElement.parentNode.removeChild(this.containerElement); |
| 44 DomContext.prototype.unload.call(this); |
| 45 }; |
| 46 |
| 47 var transformStyleProperty = features.transformStyleProperty; |
| 48 |
| 49 RenderContext.prototype.processElements = function processElements(elements,
transforms) { |
| 50 var count = transforms.length; |
| 51 var i; |
| 52 for (i = 0; i < count; ++i) { |
| 53 var element = elements[i]; |
| 54 element.style[transformStyleProperty] = transforms[i]; |
| 55 element.zIndex = i; |
| 56 |
| 57 // Elements not in the DOM need to be added |
| 58 if (!element.parentNode) { |
| 59 this.containerElement.appendChild(element); |
| 60 } |
| 61 } |
| 62 }; |
| 63 |
| 64 return function (element, frameData) { |
| 65 return new RenderContext(element, frameData); |
| 66 }; |
| 67 }); |
| OLD | NEW |