Skip to content

Commit 0e2a67c

Browse files
committed
add ease Elastic and Bounce
1 parent 40f93aa commit 0e2a67c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import QueueAnim from 'rc-queue-anim';
33
import React from 'react';
44
import ReactDom from 'react-dom';
55

6-
ReactDom.render(<QueueAnim ease="easeOutElastic" duration={1000}>
6+
ReactDom.render(<QueueAnim ease="easeInOutElastic" duration={5000}>
77
<div key="1">依次进入</div>
88
<div key="2">依次进入</div>
99
<div key="3">依次进入</div>

src/QueueAnim.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,23 @@ const _ease = {
3636
const _p1 = o >= 1 ? o : 1;
3737
const _p2 = (t || 1) / (o < 1 ? o : 1);
3838
const _p3 = _p2 / Math.PI * 2 * (Math.asin(1 / _p1) || 0);
39+
// _p2 = Math.PI * 2 / _p2;
3940
return -(_p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin((p - _p3) * _p2));
4041
},
4142
easeOutElastic: function(p, o, t) {
4243
const _p1 = o >= 1 ? o : 1;
4344
const _p2 = (t || 1) / (o < 1 ? o : 1);
4445
const _p3 = _p2 / Math.PI * 2 * (Math.asin(1 / _p1) || 0);
46+
// _p2 = Math.PI * 2 / _p2;
4547
return _p1 * Math.pow(2, -10 * p) * Math.sin((p - _p3) * _p2) + 1;
4648
},
4749
easeInOutElastic: function(_p, o, t) {
4850
let p = _p;
4951
const _p1 = o >= 1 ? o : 1;
5052
const _p2 = (t || 1) / (o < 1 ? o : 1);
5153
const _p3 = _p2 / Math.PI * 2 * (Math.asin(1 / _p1) || 0);
52-
const a = -0.5 * (_p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin((p - _p3) * _p2));
53-
const b = _p1 * Math.pow(2, -10 * (p -= 1)) * Math.sin((p - _p3) * _p2) * 0.5 + 1;
5454
p *= 2;
55-
return p < 1 ? a : b;
55+
return p < 1 ? -0.5 * (_p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin((p - _p3) * _p2)) : _p1 * Math.pow(2, -10 * (p -= 1)) * Math.sin((p - _p3) * _p2) * 0.5 + 1;
5656
},
5757
easeInBounce: function(_p) {
5858
let p = _p;

0 commit comments

Comments
 (0)