momentum.js
896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { momentum } from 'scroll/util/momentum'
describe('momentum.js', () => {
it('#momentum()', () => {
let ret = momentum(-2609, -2994, 43.4299, -3298, 0, 414, {
deceleration: 0.001,
swipeBounceTime: 500,
wheel: false,
swipeTime: 2500
})
expect(ret.destination)
.to.equal(104)
expect(ret.duration)
.to.equal(500)
ret = momentum(-311, -255, 240.975, -834, 0, 414, {
deceleration: 0.001,
swipeBounceTime: 500,
wheel: false,
swipeTime: 2500
})
expect(ret.destination)
.to.equal(-543)
expect(ret.duration)
.to.equal(2500)
ret = momentum(-1111, -834, 92.465, -1138, 0, 414, {
deceleration: 0.001,
swipeBounceTime: 500,
wheel: false,
swipeTime: 2500
})
expect(ret.destination)
.to.equal(-1221)
expect(ret.duration)
.to.equal(500)
})
})