1
- import { getRect , css , isScrolledPast , matrix , isRectEqual , indexOfObject } from './utils.js' ;
1
+ import { getRect , css , matrix , isRectEqual , indexOfObject } from './utils.js' ;
2
2
import Sortable from './Sortable.js' ;
3
3
4
4
export default function AnimationStateManager ( ) {
@@ -17,7 +17,7 @@ export default function AnimationStateManager() {
17
17
target : child ,
18
18
rect : getRect ( child )
19
19
} ) ;
20
- let fromRect = getRect ( child ) ;
20
+ let fromRect = { ... animationStates [ animationStates . length - 1 ] . rect } ;
21
21
22
22
// If animating: compensate for current animation
23
23
if ( child . thisAnimationDuration ) {
@@ -70,29 +70,6 @@ export default function AnimationStateManager() {
70
70
71
71
target . toRect = toRect ;
72
72
73
- // If element is scrolled out of view: Do not animate
74
- if (
75
- (
76
- isScrolledPast ( target , toRect , 'bottom' , 'top' ) ||
77
- isScrolledPast ( target , toRect , 'top' , 'bottom' ) ||
78
- isScrolledPast ( target , toRect , 'right' , 'left' ) ||
79
- isScrolledPast ( target , toRect , 'left' , 'right' )
80
- ) &&
81
- (
82
- isScrolledPast ( target , animatingRect , 'bottom' , 'top' ) ||
83
- isScrolledPast ( target , animatingRect , 'top' , 'bottom' ) ||
84
- isScrolledPast ( target , animatingRect , 'right' , 'left' ) ||
85
- isScrolledPast ( target , animatingRect , 'left' , 'right' )
86
- ) &&
87
- (
88
- isScrolledPast ( target , fromRect , 'bottom' , 'top' ) ||
89
- isScrolledPast ( target , fromRect , 'top' , 'bottom' ) ||
90
- isScrolledPast ( target , fromRect , 'right' , 'left' ) ||
91
- isScrolledPast ( target , fromRect , 'left' , 'right' )
92
- )
93
- ) return ;
94
-
95
-
96
73
if ( target . thisAnimationDuration ) {
97
74
// Could also check if animatingRect is between fromRect and toRect
98
75
if (
@@ -120,6 +97,7 @@ export default function AnimationStateManager() {
120
97
this . animate (
121
98
target ,
122
99
animatingRect ,
100
+ toRect ,
123
101
time
124
102
) ;
125
103
}
@@ -151,16 +129,15 @@ export default function AnimationStateManager() {
151
129
animationStates = [ ] ;
152
130
} ,
153
131
154
- animate ( target , prev , duration ) {
132
+ animate ( target , currentRect , toRect , duration ) {
155
133
if ( duration ) {
156
134
css ( target , 'transition' , '' ) ;
157
135
css ( target , 'transform' , '' ) ;
158
- let currentRect = getRect ( target ) ,
159
- elMatrix = matrix ( this . el ) ,
136
+ let elMatrix = matrix ( this . el ) ,
160
137
scaleX = elMatrix && elMatrix . a ,
161
138
scaleY = elMatrix && elMatrix . d ,
162
- translateX = ( prev . left - currentRect . left ) / ( scaleX || 1 ) ,
163
- translateY = ( prev . top - currentRect . top ) / ( scaleY || 1 ) ;
139
+ translateX = ( currentRect . left - toRect . left ) / ( scaleX || 1 ) ,
140
+ translateY = ( currentRect . top - toRect . top ) / ( scaleY || 1 ) ;
164
141
165
142
target . animatingX = ! ! translateX ;
166
143
target . animatingY = ! ! translateY ;
0 commit comments