|
24 | 24 | RAF = w.requestAnimationFrame,
|
25 | 25 | Logger = SCROLLER.Logger,
|
26 | 26 | INITIAL_SURFACES = 10;
|
27 |
| - |
| 27 | + |
| 28 | + |
28 | 29 | function SurfaceManager() {}
|
29 | 30 |
|
| 31 | + SurfaceManager.matrixTransform = function (x, y) { |
| 32 | + return 'matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,' + x +',' + y + ', 0, 1)'; |
| 33 | + }; |
| 34 | + |
| 35 | + SurfaceManager.translateTransform = function (x, y) { |
| 36 | + return 'translate3d(' + x +'px,' + y + 'px, 0)'; |
| 37 | + }; |
| 38 | + |
30 | 39 | SurfaceManager.prototype = {
|
31 | 40 | /* Bootstrap function */
|
32 | 41 | init: function () {
|
|
39 | 48 | this.on('destroy', this._destroySurfaceManager);
|
40 | 49 | },
|
41 | 50 | _initializeSurfaceManager: function () {
|
| 51 | + this._initTransformFunction(); |
42 | 52 | this._bootstrapItems();
|
43 | 53 | this._initializeSurfaces();
|
44 | 54 | this._setActiveOffset();
|
45 | 55 | this._initializePositions();
|
46 | 56 | this._setInfiniteScrollerSize();
|
| 57 | + this._setWrapperState(); |
| 58 | + |
| 59 | + }, |
| 60 | + _initTransformFunction: function () { |
| 61 | + this._transformFnc = this.opts.useNativeScroller ? SurfaceManager.translateTransform : SurfaceManager.matrixTransform; |
| 62 | + }, |
| 63 | + _setWrapperState: function () { |
| 64 | + if (this.opts.useNativeScroller) { |
| 65 | + // Using native scroller, we dont need the "scroller" div anymore |
| 66 | + this.wrapper.removeChild(this.scroller); |
| 67 | + } |
| 68 | + |
47 | 69 | },
|
48 | 70 | _destroySurfaceManager: function () {
|
49 | 71 | var docfrag = w.document.createDocumentFragment();
|
|
161 | 183 | offsetX = config.preCalculateSize ? offset - width : offset;
|
162 | 184 | }
|
163 | 185 |
|
164 |
| - surface.dom.style[STYLES.transform] = 'matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,' + offsetX +',' + offsetY + ', 0, 1)'; |
| 186 | + surface.dom.style[STYLES.transform] = this._transformFnc(offsetX, offsetY); |
165 | 187 |
|
166 | 188 | surface.state = 1;
|
167 | 189 | surface.contentIndex = index;
|
|
185 | 207 | },
|
186 | 208 | _attachSurfaces: function (surfaces) {
|
187 | 209 | var docfrag = w.document.createDocumentFragment(),
|
| 210 | + target = this.opts.useNativeScroller ? this.wrapper : this.scroller, |
188 | 211 | surface, i;
|
189 | 212 |
|
190 | 213 | for (i = 0 ; i < surfaces.length; i++) {
|
|
193 | 216 | this.surfacesPool.push(surface);
|
194 | 217 | }
|
195 | 218 |
|
196 |
| - this.scroller.appendChild(docfrag); |
| 219 | + target.appendChild(docfrag); |
197 | 220 | },
|
198 | 221 | _getAvailableSurface: function () {
|
199 | 222 | var pool = this.surfacesPool,
|
|
478 | 501 |
|
479 | 502 | if (surface) {
|
480 | 503 | diff = spaceBottom ? this.wrapperHeight : bottomOffset;
|
481 |
| - surface.style[STYLES.transform] = 'matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,' + diff + ', 0, 1)'; |
| 504 | + surface.style[STYLES.transform] = this._transformFnc(0, diff); |
482 | 505 | }
|
483 | 506 | },
|
484 | 507 | _appendPullToLoad: function () {
|
|
0 commit comments