Skip to content

Commit 42a071d

Browse files
committed
fix safari reverse flash
1 parent 60793a3 commit 42a071d

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

examples/scrollAnim.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Demo() {
1515
animation={{ y: 30, type: 'from', ease: 'easeOutQuart', opacity: 0 }}
1616
reverseDelay={200}
1717
style={{ background: '#fff000' }}
18+
1819
>
1920
执行动画
2021
</Tween>
@@ -24,6 +25,7 @@ function Demo() {
2425
animation={{ y: 30, delay: 100, ease: 'easeOutQuart', type: 'from', opacity: 0, id: 12 }}
2526
reverseDelay={100}
2627
style={{ background: '#000fff' }}
28+
onChange={(e) => {console.log(e)}}
2729
>
2830
执行动画
2931
</Tween>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-tween-one",
3-
"version": "2.2.3",
3+
"version": "2.2.4",
44
"description": "tween-one anim component for react",
55
"keywords": [
66
"react",

src/Tween.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ p.render = function () {
306306
moment: this.progressTime,
307307
...e,
308308
};
309-
if (progressTime >= 0 &&
309+
if (progressTime >= (item.delay && reverse ? -this.perFrame + this.accuracy : 0) &&
310310
!(progressTime > duration && item.mode === 'onComplete') &&
311311
this.start[i]) {
312312
const updateAnim = this.updateAnim === 'update';
313-
progressTime = progressTime < this.perFrame - this.accuracy ? 0 : progressTime;
313+
progressTime = (progressTime < this.perFrame - this.accuracy) && !reverse ? 0 : progressTime;
314314
if (((progressTime >= duration - this.accuracy && !reverse) || (reverse && progressTime <= 0))
315315
&& repeatNum >= item.repeat) {
316316
// onReveresComplete 和 onComplete 统一用 onComplete;

src/TweenOne.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class TweenOne extends Component {
185185
this.startFrame = ticker.frame;
186186
this.tween.reverse = this.reverse;
187187
this.tween.reverseStartTime = this.startMoment;
188+
this.raf();
188189
this.play();
189190
}
190191

@@ -224,7 +225,7 @@ class TweenOne extends Component {
224225
let repeatNum = Math.floor(moment / this.tween.totalTime) || 0;
225226
repeatNum = repeatNum > repeat ? repeat : repeatNum;
226227
let tweenMoment = moment - this.tween.totalTime * repeatNum;
227-
tweenMoment = tweenMoment < perFrame ? 0 : tweenMoment;
228+
tweenMoment = tweenMoment < perFrame && !this.reverse ? 0 : tweenMoment;
228229
if (repeat && moment && moment - this.tween.totalTime * repeatNum < perFrame) {
229230
// 在重置样式之前补 complete;
230231
this.tween.frame(this.tween.totalTime * repeatNum);

0 commit comments

Comments
 (0)