1
1
'use strict' ;
2
2
/* global document, window */
3
- var stateFromOptions = require ( './state.js' ) . stateFromOptions ;
4
- var Animation = require ( './animation.js' ) ;
5
- var createState = require ( './state.js' ) . createState ;
3
+ const stateFromOptions = require ( './state.js' ) . stateFromOptions ;
4
+ const Animation = require ( './animation.js' ) ;
5
+ const createState = require ( './state.js' ) . createState ;
6
+ const utils = require ( './utils.js' ) ;
6
7
7
- var Engine = {
8
+ const Engine = {
8
9
runningAnimations : [ ] ,
9
10
completedAnimations : [ ] ,
10
11
transformProperty : 'transform' ,
11
12
rAFScheduled : false ,
12
13
init ( ) {
13
14
if ( typeof window !== undefined ) return ;
14
- var styles = window . getComputedStyle ( document . documentElement , '' ) ;
15
- var vendorPrefix = ( Array . prototype . slice
15
+ const styles = window . getComputedStyle ( document . documentElement , '' ) ;
16
+ const vendorPrefix = ( Array . prototype . slice
16
17
. call ( styles )
17
18
. join ( '' )
18
19
. match ( / - ( m o z | w e b k i t | m s ) - / ) || styles . OLink === '' && [ '' , 'o' ]
@@ -34,8 +35,8 @@ var Engine = {
34
35
35
36
stepAnimations ( time ) {
36
37
this . runningAnimations . forEach ( ( runningAnimation ) => {
37
- var element = runningAnimation [ 0 ] ;
38
- var animation = runningAnimation [ 1 ] ;
38
+ const element = runningAnimation [ 0 ] ;
39
+ const animation = runningAnimation [ 1 ] ;
39
40
this . stepAnimation ( element , animation , time ) ;
40
41
} ) ;
41
42
@@ -53,12 +54,12 @@ var Engine = {
53
54
} ,
54
55
55
56
archiveCompletedAnimations ( ) {
56
- var unFinished = this . runningAnimations . filter ( ( animation ) => ! animation [ 1 ] . completed ( ) ) ;
57
- var finished = this . runningAnimations . filter ( ( animation ) => animation [ 1 ] . completed ( ) ) ;
57
+ const unFinished = this . runningAnimations . filter ( ( animation ) => ! animation [ 1 ] . completed ( ) ) ;
58
+ const finished = this . runningAnimations . filter ( ( animation ) => animation [ 1 ] . completed ( ) ) ;
58
59
59
- var queuedAnimations = this . createQueuedAnimations ( finished ) ;
60
+ const queuedAnimations = this . createQueuedAnimations ( finished ) ;
60
61
// Finished and not queued
61
- var completed = finished . filter ( ( finishedAnimation ) => {
62
+ const completed = finished . filter ( ( finishedAnimation ) => {
62
63
return ! queuedAnimations . find ( ( queuedAnimation ) => {
63
64
return queuedAnimation [ 0 ] !== finishedAnimation [ 0 ] ;
64
65
} ) ;
@@ -79,11 +80,11 @@ var Engine = {
79
80
80
81
// Call complete callback
81
82
finished . forEach ( ( animation ) => {
82
- var completeCallback = animation [ 1 ] . options . complete ;
83
+ const completeCallback = animation [ 1 ] . options . complete ;
83
84
if ( completeCallback )
84
85
completeCallback ( ) ;
85
86
} ) ;
86
-
87
+ //this.clearOphanedEndStates();
87
88
} ,
88
89
89
90
createQueuedAnimations ( finished ) {
@@ -155,6 +156,12 @@ var Engine = {
155
156
if ( match ) {
156
157
return match [ 1 ] . endState ( ) ;
157
158
}
159
+ } ,
160
+
161
+ clearOphanedEndStates ( ) {
162
+ this . completedAnimations = this . completedAnimations . filter ( ( animation ) => {
163
+ return utils . findUltimateAncestor ( animation [ 0 ] . body ) ;
164
+ } ) ;
158
165
}
159
166
} ;
160
167
0 commit comments