-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
45 lines (40 loc) · 1.06 KB
/
test.js
File metadata and controls
45 lines (40 loc) · 1.06 KB
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
39
40
41
42
43
44
45
import { ready, get, on } from 'uc-dom'
import scroll from './index'
ready(() => {
const elHeader = get('header').item(0)
on(elHeader, 'click', 'a', e => {
e.preventDefault();
scroll.to(window, {
to: e.target.hash,
ease: 'inOutExpo',
duration: 1500
});
});
const elScroll = get('#scroll');
const elContent = get('#content');
on(elContent, 'click', 'a.child', e => {
e.preventDefault();
scroll.to(elScroll, {
to: { top: 200, left: 50 },
direction: 'both',
shiftTop: 50,
ease: 'inOutExpo'
}, () => console.log('done'));
});
scroll.on(window, {
on: '#content',
condition: 'top(20) and bottom(-20)'
}, (condition, event) => {
event.target.style.background = condition ? '#006600' : '#660000';
});
scroll.on(elScroll, {
on: '#rollon',
condition: 'middle'
}, (condition, event) => {
console.log('box', condition);
event.target.style.background = condition ? '#006600' : '#660000';
});
scroll.direction(window, cond => {
console.log('direction', cond)
});
});