File tree 6 files changed +21
-6
lines changed
6 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 106
106
< button class ="pause "> Pause</ button >
107
107
< button class ="reverse "> Reverse</ button >
108
108
< button class ="restart "> Restart</ button >
109
+ < label > Is reversed : < input class ="is-reversed "> </ input > </ label >
109
110
</ div >
110
111
< div class ="timeline ">
111
112
< input class ="progress " type ="range " min ="0 " max ="100 " step =".1 " value ="0 ">
122
123
123
124
var els = document . querySelectorAll ( '.el' ) ;
124
125
var controlsProgressEl = document . querySelector ( '.controls .progress' ) ;
126
+ var isReversedEl = document . querySelector ( '.is-reversed' ) ;
125
127
126
128
window . tl = anime . timeline ( {
127
129
targets : els ,
128
130
duration : 800 ,
129
131
delay : function ( el , i ) { return 75 * i ; } ,
130
132
update : function ( anim ) {
131
133
controlsProgressEl . value = anim . progress ;
134
+ isReversedEl . value = anim . reversePlayback ;
132
135
} ,
133
136
loopComplete : ( a ) => console . log ( 'TL loop completed' ) ,
134
137
autoplay : true ,
135
- easing : 'easeOutQuad'
138
+ easing : 'easeOutQuad' ,
139
+ direction : 'alternate'
136
140
} ) ;
137
141
138
142
document . querySelector ( '.controls .play' ) . onclick = tl . play ;
Original file line number Diff line number Diff line change @@ -2683,7 +2683,6 @@ <h3 class="demo-title">Reverse</h3>
2683
2683
targets : '.reverse-anim-demo .el' ,
2684
2684
translateX : 270 ,
2685
2685
loop : true ,
2686
- direction : 'alternate' ,
2687
2686
delay : function ( el , i ) { return i * 200 ; } ,
2688
2687
easing : 'easeInOutSine'
2689
2688
} ) ;
Original file line number Diff line number Diff line change @@ -938,6 +938,10 @@ function anime(params) {
938
938
var promise = makePromise ( instance ) ;
939
939
940
940
function toggleInstanceDirection ( ) {
941
+ var direction = instance . direction ;
942
+ if ( direction !== 'alternate' ) {
943
+ instance . direction = direction !== 'normal' ? 'normal' : 'reverse' ;
944
+ }
941
945
instance . reversed = ! instance . reversed ;
942
946
children . forEach ( function ( child ) { return child . reversed = instance . reversed ; } ) ;
943
947
}
@@ -1136,8 +1140,8 @@ function anime(params) {
1136
1140
1137
1141
instance . play = function ( ) {
1138
1142
if ( ! instance . paused ) { return ; }
1143
+ if ( instance . completed ) { instance . reset ( ) ; }
1139
1144
instance . paused = false ;
1140
- instance . completed = false ;
1141
1145
activeInstances . push ( instance ) ;
1142
1146
resetTime ( ) ;
1143
1147
if ( ! raf ) { engine ( ) ; }
Original file line number Diff line number Diff line change @@ -940,6 +940,10 @@ function anime(params) {
940
940
var promise = makePromise ( instance ) ;
941
941
942
942
function toggleInstanceDirection ( ) {
943
+ var direction = instance . direction ;
944
+ if ( direction !== 'alternate' ) {
945
+ instance . direction = direction !== 'normal' ? 'normal' : 'reverse' ;
946
+ }
943
947
instance . reversed = ! instance . reversed ;
944
948
children . forEach ( function ( child ) { return child . reversed = instance . reversed ; } ) ;
945
949
}
@@ -1138,8 +1142,8 @@ function anime(params) {
1138
1142
1139
1143
instance . play = function ( ) {
1140
1144
if ( ! instance . paused ) { return ; }
1145
+ if ( instance . completed ) { instance . reset ( ) ; }
1141
1146
instance . paused = false ;
1142
- instance . completed = false ;
1143
1147
activeInstances . push ( instance ) ;
1144
1148
resetTime ( ) ;
1145
1149
if ( ! raf ) { engine ( ) ; }
Original file line number Diff line number Diff line change @@ -918,6 +918,10 @@ function anime(params = {}) {
918
918
let promise = makePromise ( instance ) ;
919
919
920
920
function toggleInstanceDirection ( ) {
921
+ const direction = instance . direction ;
922
+ if ( direction !== 'alternate' ) {
923
+ instance . direction = direction !== 'normal' ? 'normal' : 'reverse' ;
924
+ }
921
925
instance . reversed = ! instance . reversed ;
922
926
children . forEach ( child => child . reversed = instance . reversed ) ;
923
927
}
@@ -1116,8 +1120,8 @@ function anime(params = {}) {
1116
1120
1117
1121
instance . play = function ( ) {
1118
1122
if ( ! instance . paused ) return ;
1123
+ if ( instance . completed ) instance . reset ( ) ;
1119
1124
instance . paused = false ;
1120
- instance . completed = false ;
1121
1125
activeInstances . push ( instance ) ;
1122
1126
resetTime ( ) ;
1123
1127
if ( ! raf ) engine ( ) ;
You can’t perform that action at this time.
0 commit comments