Permalink
Browse files

refactor: improve tree shaking abilities

Internal refactor completed in order to improve tree shaking and dead
code removal. The public API, with an exception to ion-slides, has
stayed the same. However, internally many changes were required so
bundlers could better exclude modules which should not be bundled.
Ultimately most changes resorted to removing references to `window` or
`document`, or a module that referenced one of those.

BREAKING CHANGES

ion-slides was refactored to remove the external dependencies, and
rewritten in TypeScript/ES6 modules to again improve tree shaking
abilities.
  • Loading branch information...
1 parent 13cf6a6 commit 7000b1b173a41eb121a0c51da41c9a00f4fc2f33 @adamdbradley adamdbradley committed Jan 9, 2017
Showing with 9,340 additions and 13,603 deletions.
  1. +1 βˆ’0 package.json
  2. +1 βˆ’1 scripts/demos/demos.template.dev.html
  3. +1 βˆ’1 scripts/demos/demos.template.prod.html
  4. +1 βˆ’4 scripts/gulp/tasks/build.ts
  5. +1 βˆ’1 scripts/gulp/tasks/clean.ts
  6. +2 βˆ’6 scripts/gulp/tasks/demos.dev.ts
  7. +2 βˆ’6 scripts/gulp/tasks/e2e.dev.ts
  8. +1 βˆ’12 scripts/gulp/util.ts
  9. +12 βˆ’4 scripts/karma/karma.config.ts
  10. +29 βˆ’0 scripts/polyfill/polyfill.dom.js
  11. +27 βˆ’29 src/animations/animation.ts
  12. +7 βˆ’6 src/components/action-sheet/action-sheet-component.ts
  13. +12 βˆ’12 src/components/action-sheet/action-sheet-transitions.ts
  14. +3 βˆ’3 src/components/action-sheet/test/basic/app-module.ts
  15. +7 βˆ’7 src/components/alert/alert-component.ts
  16. +12 βˆ’12 src/components/alert/alert-transitions.ts
  17. +9 βˆ’11 src/components/app/app-root.ts
  18. +5 βˆ’6 src/components/app/app.ts
  19. +4 βˆ’4 src/components/app/test/animations/app-module.ts
  20. +35 βˆ’31 src/components/app/test/app.spec.ts
  21. +1 βˆ’1 src/components/badge/badge.ts
  22. +1 βˆ’1 src/components/button/button.ts
  23. +4 βˆ’0 src/components/button/test/basic/app-module.ts
  24. +2 βˆ’2 src/components/button/test/basic/main.html
  25. +1 βˆ’1 src/components/card/card.ts
  26. +5 βˆ’3 src/components/checkbox/checkbox.ts
  27. +1 βˆ’1 src/components/chip/chip.ts
  28. +1 βˆ’0 src/components/content/content.scss
  29. +44 βˆ’26 src/components/content/content.ts
  30. +4 βˆ’4 src/components/datetime/datetime.ts
  31. +15 βˆ’11 src/components/fab/fab.ts
  32. +1 βˆ’1 src/components/icon/icon.ts
  33. +4 βˆ’7 src/components/img/img.ts
  34. +14 βˆ’7 src/components/img/test/img.spec.ts
  35. +1 βˆ’1 src/components/infinite-scroll/infinite-scroll.ts
  36. +5 βˆ’4 src/components/infinite-scroll/test/infinite-scroll.spec.ts
  37. +0 βˆ’609 src/components/input/input-base.ts
  38. +1 βˆ’1 src/components/input/input.ios.scss
  39. +596 βˆ’153 src/components/input/input.ts
  40. +28 βˆ’25 src/components/input/native-input.ts
  41. +18 βˆ’18 src/components/input/test/floating-labels/main.html
  42. +1 βˆ’1 src/components/input/test/text-input.spec.ts
  43. +0 βˆ’33 src/components/ion.ts
  44. +28 βˆ’19 src/components/item/item-reorder-gesture.ts
  45. +31 βˆ’0 src/components/item/item-reorder-util.ts
  46. +21 βˆ’47 src/components/item/item-reorder.ts
  47. +7 βˆ’5 src/components/item/item-sliding-gesture.ts
  48. +26 βˆ’18 src/components/item/item-sliding.ts
  49. +4 βˆ’4 src/components/item/item.ts
  50. +1 βˆ’1 src/components/label/label.ts
  51. +6 βˆ’4 src/components/list/list.ts
  52. +5 βˆ’4 src/components/loading/loading-component.ts
  53. +12 βˆ’12 src/components/loading/loading-transitions.ts
  54. +2 βˆ’2 src/components/menu/menu-controller.ts
  55. +5 βˆ’3 src/components/menu/menu-gestures.ts
  56. +14 βˆ’13 src/components/menu/menu-types.ts
  57. +14 βˆ’13 src/components/menu/menu.ts
  58. +1 βˆ’1 src/components/modal/modal-component.ts
  59. +9 βˆ’11 src/components/modal/modal-transitions.ts
  60. +17 βˆ’17 src/components/modal/test/basic/app-module.ts
  61. +5 βˆ’3 src/components/nav/nav.ts
  62. +5 βˆ’3 src/components/nav/overlay-portal.ts
  63. +1 βˆ’1 src/components/note/note.ts
  64. +23 βˆ’31 src/components/picker/picker-component.ts
  65. +4 βˆ’4 src/components/picker/picker-transitions.ts
  66. +4 βˆ’4 src/components/popover/popover-component.ts
  67. +15 βˆ’16 src/components/popover/popover-transitions.ts
  68. +1 βˆ’1 src/components/radio/radio-button.ts
  69. +4 βˆ’2 src/components/radio/radio-group.ts
  70. +3 βˆ’3 src/components/radio/test/radio.spec.ts
  71. +59 βˆ’0 src/components/range/range-knob.ts
  72. +245 βˆ’339 src/components/range/range.ts
  73. +20 βˆ’17 src/components/range/test/range.spec.ts
  74. +17 βˆ’12 src/components/refresher/refresher.ts
  75. +32 βˆ’27 src/components/refresher/test/refresher.spec.ts
  76. +10 βˆ’6 src/components/searchbar/searchbar.ts
  77. +1 βˆ’1 src/components/segment/segment.ts
  78. +3 βˆ’3 src/components/segment/test/swipe/app-module.ts
  79. +1 βˆ’1 src/components/segment/test/swipe/main.html
  80. +3 βˆ’3 src/components/select/select.ts
  81. +9 βˆ’11 src/components/show-hide-when/show-hide-when.ts
  82. +43 βˆ’0 src/components/slides/slide.ts
  83. +222 βˆ’166 src/components/slides/slides.scss
  84. +541 βˆ’572 src/components/slides/slides.ts
  85. +0 βˆ’12 src/components/slides/swiper-widget.d.ts
  86. +0 βˆ’3,953 src/components/slides/swiper-widget.es2015.js
  87. +0 βˆ’3,954 src/components/slides/swiper-widget.js
  88. +0 βˆ’289 src/components/slides/swiper-widget.system.js
  89. +104 βˆ’0 src/components/slides/swiper/swiper-a11y.ts
  90. +99 βˆ’0 src/components/slides/swiper/swiper-classes.ts
  91. +328 βˆ’0 src/components/slides/swiper/swiper-effects.ts
  92. +855 βˆ’0 src/components/slides/swiper/swiper-events.ts
  93. +41 βˆ’0 src/components/slides/swiper/swiper-index.ts
  94. +90 βˆ’0 src/components/slides/swiper/swiper-interfaces.ts
  95. +115 βˆ’0 src/components/slides/swiper/swiper-keyboard.ts
  96. +94 βˆ’0 src/components/slides/swiper/swiper-pagination.ts
  97. +68 βˆ’0 src/components/slides/swiper/swiper-parallax.ts
  98. +72 βˆ’0 src/components/slides/swiper/swiper-progress.ts
  99. +137 βˆ’0 src/components/slides/swiper/swiper-transition.ts
  100. +188 βˆ’0 src/components/slides/swiper/swiper-utils.ts
  101. +526 βˆ’0 src/components/slides/swiper/swiper-zoom.ts
  102. +924 βˆ’0 src/components/slides/swiper/swiper.ts
  103. +18 βˆ’30 src/components/slides/test/basic/app-module.ts
  104. +18 βˆ’10 src/components/slides/test/basic/main.html
  105. +0 βˆ’4 src/components/slides/test/controller/app-module.ts
  106. +36 βˆ’23 src/components/slides/test/controller/main.html
  107. +62 βˆ’0 src/components/slides/test/images/app-module.ts
  108. +17 βˆ’0 src/components/slides/test/images/main.html
  109. +9 βˆ’10 src/components/slides/test/intro/app-module.ts
  110. +9 βˆ’1 src/components/slides/test/intro/main.html
  111. +12 βˆ’3 src/components/slides/test/loop/app-module.ts
  112. +3 βˆ’2 src/components/slides/test/loop/main.html
  113. +13 βˆ’3 src/components/slides/test/scroll/app-module.ts
  114. +17 βˆ’3 src/components/slides/test/scroll/main.html
  115. +22 βˆ’9 src/components/spinner/spinner.ts
  116. +21 βˆ’14 src/components/tabs/tab-highlight.ts
  117. +7 βˆ’6 src/components/tabs/tab.ts
  118. +53 βˆ’38 src/components/tabs/tabs.ts
  119. +43 βˆ’3 src/components/tabs/test/advanced/app-module.ts
  120. +2 βˆ’0 src/components/tabs/test/advanced/tab1page1.html
  121. +1 βˆ’0 src/components/tabs/test/advanced/tabs.html
  122. +102 βˆ’0 src/components/tabs/test/events/app-module.ts
  123. +0 βˆ’170 src/components/tap-click/test/activator.spec.ts
  124. +0 βˆ’171 src/components/tap-click/test/click-block/app-module.ts
  125. +0 βˆ’54 src/components/tap-click/test/click-block/main.html
  126. +0 βˆ’42 src/components/tap-click/test/click-block/modal.html
  127. +3 βˆ’7 src/components/toast/test/toast.spec.ts
  128. +6 βˆ’6 src/components/toast/toast-transitions.ts
  129. +11 βˆ’6 src/components/toggle/toggle-gesture.ts
  130. +17 βˆ’12 src/components/toggle/toggle.ts
  131. +2 βˆ’2 src/components/toolbar/toolbar.ts
  132. +3 βˆ’3 src/components/virtual-scroll/test/basic/app-module.ts
  133. +81 βˆ’0 src/components/virtual-scroll/test/media/app-module.ts
  134. +6 βˆ’0 src/components/virtual-scroll/test/media/e2e.ts
  135. +23 βˆ’0 src/components/virtual-scroll/test/media/main.html
  136. +2 βˆ’2 src/components/virtual-scroll/test/sliding-item/app-module.ts
  137. +3 βˆ’2 src/components/virtual-scroll/test/virtual-scroll.spec.ts
  138. +14 βˆ’14 src/components/virtual-scroll/virtual-scroll.ts
  139. +10 βˆ’11 src/components/virtual-scroll/virtual-util.ts
  140. +31 βˆ’26 src/config/config.ts
  141. +111 βˆ’112 src/config/test/config.spec.ts
  142. +0 βˆ’254 src/directives.ts
  143. +34 βˆ’34 src/gestures/drag-gesture.ts
  144. +2 βˆ’2 src/gestures/gesture.ts
  145. +7 βˆ’8 src/gestures/hammer.ts
  146. +137 βˆ’0 src/gestures/pointer-events.ts
  147. +6 βˆ’5 src/gestures/slide-edge-gesture.ts
  148. +3 βˆ’2 src/gestures/slide-gesture.ts
  149. +52 βˆ’0 src/gestures/ui-event-manager.ts
  150. +560 βˆ’19 src/index.ts
  151. +0 βˆ’240 src/module.ts
  152. +6 βˆ’4 src/navigation/nav-controller-base.ts
  153. +11 βˆ’11 src/navigation/nav-controller.ts
  154. +4 βˆ’2 src/navigation/swipe-back.ts
  155. +0 βˆ’80 src/navigation/test/nav-controller.spec.ts
  156. +12 βˆ’2 src/navigation/view-controller.ts
  157. +61 βˆ’37 src/{util β†’ platform}/dom-controller.ts
  158. 0 src/{util β†’ platform}/key.ts
  159. +52 βˆ’37 src/{util β†’ platform}/keyboard.ts
  160. +63 βˆ’94 src/platform/platform-registry.ts
  161. +28 βˆ’0 src/platform/platform-utils.ts
  162. +382 βˆ’106 src/platform/platform.ts
  163. +3 βˆ’17 src/platform/query-params.ts
  164. +199 βˆ’217 src/platform/test/platform.spec.ts
  165. +34 βˆ’17 src/platform/test/query-params.spec.ts
  166. +1 βˆ’1 src/{components β†’ }/tap-click/activator-base.ts
  167. +25 βˆ’24 src/{components β†’ }/tap-click/activator.ts
  168. +17 βˆ’45 src/{util β†’ tap-click}/haptic.ts
  169. +13 βˆ’11 src/{components β†’ }/tap-click/ripple.ts
  170. +31 βˆ’22 src/{components β†’ }/tap-click/tap-click.ts
  171. +146 βˆ’0 src/tap-click/test/activator.spec.ts
  172. 0 src/{components/tap-click/test/tapClick.spec.ts β†’ tap-click/test/tap-click.spec.ts}
  173. +7 βˆ’23 src/transitions/page-transition.ts
  174. +4 βˆ’3 src/transitions/transition-controller.ts
  175. +15 βˆ’14 src/transitions/transition-ios.ts
  176. +4 βˆ’3 src/transitions/transition-md.ts
  177. +3 βˆ’2 src/transitions/transition-registry.ts
  178. +4 βˆ’3 src/transitions/transition-wp.ts
  179. +3 βˆ’2 src/transitions/transition.ts
  180. +4 βˆ’3 src/util/click-block.ts
  181. +2 βˆ’2 src/util/datetime-util.ts
  182. +26 βˆ’255 src/util/dom.ts
  183. +16 βˆ’19 src/util/events.ts
  184. +6 βˆ’1 src/util/form.ts
  185. +210 βˆ’117 src/util/mock-providers.ts
  186. +50 βˆ’40 src/util/scroll-view.ts
  187. +221 βˆ’0 src/util/test/mock-providers.spec.ts
  188. +0 βˆ’23 src/util/test/util.spec.ts
  189. +0 βˆ’256 src/util/ui-event-manager.ts
  190. +49 βˆ’73 src/util/util.ts
  191. +4 βˆ’0 tsconfig.json
View
@@ -102,6 +102,7 @@
"karma-coverage": "1.1.1",
"karma-jasmine": "1.0.2",
"karma-sourcemap-loader": "0.3.7",
+ "karma-spec-reporter": "0.0.26",
"merge2": "1.0.2",
"mkdirp": "0.5.1",
"node-html-encoder": "0.0.2",
@@ -36,7 +36,7 @@
}
});
</script>
- <script src="../polyfills/polyfills.ng.js"></script>
+ <script src="../polyfills/polyfills.js"></script>
<script src="../../bundles/ionic.system.js"></script>
</head>
@@ -13,7 +13,7 @@
<ion-app></ion-app>
- <script src="../polyfills/polyfills.ng.js"></script>
+ <script src="../polyfills/polyfills.js"></script>
<script src="./build/main.js"></script>
</body>
</html>
@@ -1,6 +1,6 @@
import { task } from 'gulp';
import { DIST_BUILD_ROOT, DIST_BUILD_ES2015_ROOT, DIST_BUILD_UMD_ROOT, ES5, ES_2015, PROJECT_ROOT, UMD_MODULE } from '../constants';
-import { copySourceToDest, copySwiperToPath, createTempTsConfig, deleteFiles, runNgc } from '../util';
+import { copySourceToDest, createTempTsConfig, deleteFiles, runNgc } from '../util';
export function buildIonicAngularUmd(excludeSpec: boolean, stripDebug: boolean, done: Function) {
@@ -14,7 +14,6 @@ export function buildIonicAngularUmd(excludeSpec: boolean, stripDebug: boolean,
return;
}
- copySwiperToPath(`${DIST_BUILD_UMD_ROOT}/components/slides`, UMD_MODULE);
// clean up any .ts files that remain as well as ngc metadata
deleteFiles([`${DIST_BUILD_UMD_ROOT}/**/*.ts`,
`${DIST_BUILD_UMD_ROOT}/node_modules`,
@@ -34,7 +33,6 @@ export function buildIonicAngularEsm(stripDebug: boolean, done: Function) {
done(err);
return;
}
- copySwiperToPath(`${DIST_BUILD_ROOT}/components/slides`, ES_2015);
// clean up any .ts files that remain as well as ngc metadata
deleteFiles([`${DIST_BUILD_ROOT}/**/*.ts`,
`${DIST_BUILD_ROOT}/node_modules`,
@@ -54,7 +52,6 @@ export function buildIonicPureEs6(stripDebug: boolean, done: Function) {
done(err);
return;
}
- copySwiperToPath(`${DIST_BUILD_ES2015_ROOT}/components/slides`, ES_2015);
// clean up any .ts files that remain as well as ngc metadata
deleteFiles([`${DIST_BUILD_ES2015_ROOT}/**/*.ts`,
`${DIST_BUILD_ES2015_ROOT}/node_modules`,
@@ -10,7 +10,7 @@ task('clean', (done: Function) => {
});
task('clean.src', (done: Function) => {
- del(['src/**/*.js', 'src/**/*.d.ts', '!src/components/slides/swiper-widget.*']).then(() => {
+ del(['src/**/*.js', 'src/**/*.d.ts']).then(() => {
done();
}).catch(err => {
done(err);
@@ -88,12 +88,8 @@ task('demos.build', function () {
* Creates SystemJS bundle from Ionic source files.
*/
task('demos.bundle', function () {
- var tsResult = tsCompile(getTscOptions('es6'), 'system')
- .pipe(babel(babelOptions));
-
- var swiper = src('src/components/slides/swiper-widget.system.js');
-
- return merge([tsResult, swiper])
+ return tsCompile(getTscOptions('es6'), 'system')
+ .pipe(babel(babelOptions))
.pipe(remember('system'))
.pipe(concat('ionic.system.js'))
.pipe(dest(`${DIST_NAME}/bundles`))
@@ -127,12 +127,8 @@ task('e2e.build', function () {
* Creates SystemJS bundle from Ionic source files.
*/
task('e2e.bundle', function () {
- var tsResult = tsCompile(getTscOptions('es6'), 'system')
- .pipe(babel(babelOptions));
-
- var swiper = src('src/components/slides/swiper-widget.system.js');
-
- return merge([tsResult, swiper])
+ return tsCompile(getTscOptions('es6'), 'system')
+ .pipe(babel(babelOptions))
.pipe(remember('system'))
.pipe(concat('ionic.system.js'))
.pipe(dest(`${DIST_NAME}/bundles`))
View
@@ -1,4 +1,4 @@
-import { UMD_MODULE, ES_2015, NODE_MODULES_ROOT, PROJECT_ROOT, SRC_ROOT, SRC_COMPONENTS_ROOT } from './constants';
+import { NODE_MODULES_ROOT, PROJECT_ROOT, SRC_ROOT } from './constants';
import { src, dest } from 'gulp';
import { join } from 'path';
import * as fs from 'fs';
@@ -138,17 +138,6 @@ export function copyFile(srcPath: string, destPath: string) {
fs.writeFileSync(destPath, sourceData);
}
-export function copySwiperToPath(distPath: string, moduleType: string) {
- copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.d.ts`, `${distPath}/swiper-widget.d.ts`);
- if (!moduleType || moduleType === UMD_MODULE) {
- copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.js`, `${distPath}/swiper-widget.js`);
- } else if (moduleType === ES_2015) {
- copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.es2015.js`, `${distPath}/swiper-widget.js`);
- } else {
- copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.system.js`, `${distPath}/swiper-widget.system.js`);
- }
-}
-
export function runNgc(pathToConfigFile: string, done: Function) {
let exec = require('child_process').exec;
var shellCommand = `node --max_old_space_size=8096 ${PROJECT_ROOT}/node_modules/.bin/ngc -p ${pathToConfigFile}`;
@@ -12,7 +12,8 @@ export function config(config) {
require('karma-jasmine'),
require('karma-coverage'),
require('karma-sourcemap-loader'),
- require('karma-chrome-launcher')
+ require('karma-chrome-launcher'),
+ require('karma-spec-reporter')
],
files: [
{pattern: 'dist/vendor/core-js/client/core.js', included: true, watched: false},
@@ -37,16 +38,23 @@ export function config(config) {
customLaunchers: customLaunchers,
exclude: [
- 'dist/e2e/**/*',
- 'dist/ionic-angular/components/slides/swiper-widget*'
+ 'dist/e2e/**/*'
],
// Source files that you wanna generate coverage for.
// Do not include tests or libraries (these files will be instrumented by Istanbul)
preprocessors: {
'dist/ionic-angular/umd/**/!(*spec).js': ['coverage'],
'dist/ionic-angular/**/*.js': ['sourcemap']
},
- reporters: ['dots', 'coverage'],
+ reporters: ['dots', 'coverage', 'spec'],
+ specReporter: {
+ maxLogLines: 5, // limit number of lines logged per test
+ suppressErrorSummary: true, // do not print error summary
+ suppressFailed: false, // do not print information about failed tests
+ suppressPassed: false, // do not print information about passed tests
+ suppressSkipped: true, // do not print information about skipped tests
+ showSpecTiming: false // print the time elapsed for each spec
+ },
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
@@ -27,4 +27,33 @@
};
}
+
+ // requestAnimationFrame polyfill by Erik MΓΆller. fixes from Paul Irish and Tino Zijdel
+ // MIT license
+ var win = window;
+ if (!win.requestAnimationFrame) {
+ win.requestAnimationFrame = win.webkitRequestAnimationFrame;
+ win.cancelAnimationFrame = win.webkitCancelAnimationFrame || win.webkitCancelRequestAnimationFrame;
+
+ if (!win.requestAnimationFrame) {
+ win.requestAnimationFrame = function(callback, element) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
+
+ var id = win.setTimeout(function() {
+ callback(currTime + timeToCall);
+ }, timeToCall);
+
+ lastTime = currTime + timeToCall;
+ return id;
+ };
+ }
+
+ if (!win.cancelAnimationFrame) {
+ win.cancelAnimationFrame = function(id) {
+ clearTimeout(id);
+ };
+ }
+ }
+
})();
@@ -1,5 +1,5 @@
-import { CSS, nativeRaf, transitionEnd, nativeTimeout } from '../util/dom';
import { isDefined, assert } from '../util/util';
+import { Platform } from '../platform/platform';
/**
@@ -30,24 +30,24 @@ export class Animation {
private _hasDur: boolean;
private _isAsync: boolean;
private _twn: boolean;
- private _raf: Function;
+ plt: Platform;
parent: Animation;
opts: AnimationOptions;
hasChildren: boolean = false;
isPlaying: boolean = false;
hasCompleted: boolean = false;
- constructor(ele?: any, opts?: AnimationOptions, raf?: Function) {
+ constructor(plt: Platform, ele?: any, opts?: AnimationOptions) {
+ this.plt = plt;
this.element(ele);
this.opts = opts;
- this._raf = raf || nativeRaf;
}
element(ele: any): Animation {
if (ele) {
if (typeof ele === 'string') {
- ele = document.querySelectorAll(ele);
+ ele = this.plt.doc().querySelectorAll(ele);
for (var i = 0; i < ele.length; i++) {
this._addEle(ele[i]);
}
@@ -155,7 +155,7 @@ export class Animation {
if (clearProperyAfterTransition) {
// if this effect is a transform then clear the transform effect
// otherwise just clear the actual property
- this.afterClearStyles([ fx.trans ? CSS.transform : prop]);
+ this.afterClearStyles([ fx.trans ? this.plt.Css.transform : prop]);
}
return this;
@@ -187,13 +187,13 @@ export class Animation {
if (!fxProp) {
// first time we've see this EffectProperty
- var shouldTrans = (TRANSFORMS[prop] === 1);
+ var shouldTrans = (ANIMATION_TRANSFORMS[prop] === 1);
fxProp = {
name: prop,
trans: shouldTrans,
// add the will-change property for transforms or opacity
- wc: (shouldTrans ? CSS.transform : prop)
+ wc: (shouldTrans ? this.plt.Css.transform : prop)
};
this._fx.push(fxProp);
}
@@ -207,7 +207,7 @@ export class Animation {
fxProp[state] = fxState;
if (typeof val === 'string' && val.indexOf(' ') < 0) {
- let r = val.match(CSS_VALUE_REGEX);
+ let r = val.match(ANIMATION_CSS_VALUE_REGEX);
let num = parseFloat(r[1]);
if (!isNaN(num)) {
@@ -323,7 +323,7 @@ export class Animation {
*/
play(opts?: PlayOptions) {
// If the animation was already invalidated (it did finish), do nothing
- if (!this._raf) {
+ if (!this.plt) {
return;
}
@@ -346,9 +346,8 @@ export class Animation {
// from an input event, and just having one RAF would have this code
// run within the same frame as the triggering input event, and the
// input event probably already did way too much work for one frame
- this._raf(() => {
- assert(this._raf, '_raf has to be valid');
- this._raf(this._playDomInspect.bind(this, opts));
+ this.plt.raf(() => {
+ this.plt.raf(this._playDomInspect.bind(this, opts));
});
}
@@ -391,8 +390,6 @@ export class Animation {
* ROOT ANIMATION
*/
_playDomInspect(opts: PlayOptions) {
- assert(this._raf, '_raf has to be valid');
-
// fire off all the "before" function that have DOM READS in them
// elements will be in the DOM, however visibily hidden
// so we can read their dimensions if need be
@@ -411,10 +408,10 @@ export class Animation {
// ******** DOM WRITE ****************
this._playProgress(opts);
- if (this._isAsync && this._raf) {
+ if (this._isAsync && this.plt) {
// this animation has a duration so we need another RAF
// for the CSS TRANSITION properties to kick in
- this._raf(this._playToStep.bind(this, 1));
+ this.plt.raf(this._playToStep.bind(this, 1));
}
}
@@ -516,11 +513,11 @@ export class Animation {
}
// set the TRANSITION END event on one of the transition elements
- self._unrgTrns = transitionEnd(self._transEl(), onTransitionEnd);
+ self._unrgTrns = this.plt.transitionEnd(self._transEl(), onTransitionEnd, false);
// set a fallback timeout if the transition end event never fires, or is too slow
// transition end fallback: (animation duration + XXms)
- self._tm = nativeTimeout(onTransitionFallback, (dur + TRANSITION_END_FALLBACK_PADDING_MS));
+ self._tm = self.plt.timeout(onTransitionFallback, (dur + ANIMATION_TRANSITION_END_FALLBACK_PADDING_MS));
}
/**
@@ -691,7 +688,7 @@ export class Animation {
finalTransform += 'translateZ(0px)';
}
- var cssTransform = CSS.transform;
+ var cssTransform = this.plt.Css.transform;
for (i = 0; i < elements.length; i++) {
// ******** DOM WRITE ****************
(<any>elements[i].style)[cssTransform] = finalTransform;
@@ -714,9 +711,10 @@ export class Animation {
const elements = this._e;
const easing = (forcedLinearEasing ? 'linear' : this.getEasing());
const durString = dur + 'ms';
- const cssTransform = CSS.transition;
- const cssTransitionDuration = CSS.transitionDuration;
- const cssTransitionTimingFn = CSS.transitionTimingFn;
+ const Css = this.plt.Css;
+ const cssTransform = Css.transition;
+ const cssTransitionDuration = Css.transitionDuration;
+ const cssTransitionTimingFn = Css.transitionTimingFn;
let eleStyle: any;
for (var i = 0; i < this._eL; i++) {
@@ -871,7 +869,7 @@ export class Animation {
// remove the transition duration/easing
// ******** DOM WRITE ****************
- (<any>ele).style[CSS.transitionDuration] = (<any>ele).style[CSS.transitionTimingFn] = '';
+ (<any>ele).style[this.plt.Css.transitionDuration] = (<any>ele).style[this.plt.Css.transitionTimingFn] = '';
if (this._rv) {
// finished in reverse direction
@@ -1050,7 +1048,7 @@ export class Animation {
// this animation has a duration so we need another RAF
// for the CSS TRANSITION properties to kick in
- this._raf && this._raf(this._playToStep.bind(this, stepValue));
+ this.plt && this.plt.raf(this._playToStep.bind(this, stepValue));
}
}
@@ -1168,7 +1166,7 @@ export class Animation {
this._clearAsync();
- this.parent = this._e = this._rdFn = this._wrFn = this._raf = null;
+ this.parent = this.plt = this._e = this._rdFn = this._wrFn = null;
if (this._c) {
this._c.length = this._cL = 0;
@@ -1228,7 +1226,7 @@ export interface EffectState {
unit: string;
}
-const TRANSFORMS: {[key: string]: number} = {
+const ANIMATION_TRANSFORMS: {[key: string]: number} = {
'translateX': 1,
'translateY': 1,
'translateZ': 1,
@@ -1248,6 +1246,6 @@ const TRANSFORMS: {[key: string]: number} = {
'perspective': 1
};
-const CSS_VALUE_REGEX = /(^-?\d*\.?\d*)(.*)/;
+const ANIMATION_CSS_VALUE_REGEX = /(^-?\d*\.?\d*)(.*)/;
const ANIMATION_DURATION_MIN = 32;
-const TRANSITION_END_FALLBACK_PADDING_MS = 400;
+const ANIMATION_TRANSITION_END_FALLBACK_PADDING_MS = 400;
Oops, something went wrong.

0 comments on commit 7000b1b

Please sign in to comment.