1
|
import { animationstart, getStyle, on, requestAnimationFrame, toMs, win } from '../util/index';
|
2
|
|
3
|
import Accordion from './accordion';
|
4
|
import Alert from './alert';
|
5
|
import Cover from './cover';
|
6
|
import Drop from './drop';
|
7
|
import Dropdown from './dropdown';
|
8
|
import FormCustom from './form-custom';
|
9
|
import Gif from './gif';
|
10
|
import Grid from './grid';
|
11
|
import HeightMatch from './height-match';
|
12
|
import HeightViewport from './height-viewport';
|
13
|
import Hover from './hover';
|
14
|
import Icon from './icon';
|
15
|
import Margin from './margin';
|
16
|
import Modal from './modal';
|
17
|
import Nav from './nav';
|
18
|
import Navbar from './navbar';
|
19
|
import Offcanvas from './offcanvas';
|
20
|
import Responsive from './responsive';
|
21
|
import Scroll from './scroll';
|
22
|
import Scrollspy from './scrollspy';
|
23
|
import ScrollspyNav from './scrollspy-nav';
|
24
|
import Sticky from './sticky';
|
25
|
import Svg from './svg';
|
26
|
import Switcher from './switcher';
|
27
|
import Tab from './tab';
|
28
|
import Toggle from './toggle';
|
29
|
import Leader from './leader';
|
30
|
|
31
|
export default function (UIkit) {
|
32
|
|
33
|
var scroll = null, dir, ticking, resizing, started = 0;
|
34
|
|
35
|
win
|
36
|
.on('load', UIkit.update)
|
37
|
.on('resize', e => {
|
38
|
if (!resizing) {
|
39
|
requestAnimationFrame(() => {
|
40
|
UIkit.update(e);
|
41
|
resizing = false;
|
42
|
});
|
43
|
resizing = true;
|
44
|
}
|
45
|
})
|
46
|
.on('scroll', e => {
|
47
|
|
48
|
if (scroll === null) {
|
49
|
scroll = 0;
|
50
|
}
|
51
|
|
52
|
if (scroll === window.pageYOffset) {
|
53
|
return;
|
54
|
}
|
55
|
|
56
|
dir = scroll < window.pageYOffset;
|
57
|
scroll = window.pageYOffset;
|
58
|
if (!ticking) {
|
59
|
requestAnimationFrame(() => {
|
60
|
e.dir = dir ? 'down' : 'up';
|
61
|
UIkit.update(e);
|
62
|
ticking = false;
|
63
|
});
|
64
|
ticking = true;
|
65
|
}
|
66
|
});
|
67
|
|
68
|
on(document, animationstart, ({target}) => {
|
69
|
if ((getStyle(target, 'animationName') || '').match(/^uk-.*(left|right)/)) {
|
70
|
started++;
|
71
|
document.body.style.overflowX = 'hidden';
|
72
|
setTimeout(() => {
|
73
|
if (!--started) {
|
74
|
document.body.style.overflowX = '';
|
75
|
}
|
76
|
}, toMs(getStyle(target, 'animationDuration')) + 100);
|
77
|
}
|
78
|
}, true);
|
79
|
|
80
|
// core components
|
81
|
UIkit.use(Toggle);
|
82
|
UIkit.use(Accordion);
|
83
|
UIkit.use(Alert);
|
84
|
UIkit.use(Cover);
|
85
|
UIkit.use(Drop);
|
86
|
UIkit.use(Dropdown);
|
87
|
UIkit.use(FormCustom);
|
88
|
UIkit.use(HeightMatch);
|
89
|
UIkit.use(HeightViewport);
|
90
|
UIkit.use(Hover);
|
91
|
UIkit.use(Margin);
|
92
|
UIkit.use(Gif);
|
93
|
UIkit.use(Grid);
|
94
|
UIkit.use(Leader);
|
95
|
UIkit.use(Modal);
|
96
|
UIkit.use(Nav);
|
97
|
UIkit.use(Navbar);
|
98
|
UIkit.use(Offcanvas);
|
99
|
UIkit.use(Responsive);
|
100
|
UIkit.use(Scroll);
|
101
|
UIkit.use(Scrollspy);
|
102
|
UIkit.use(ScrollspyNav);
|
103
|
UIkit.use(Sticky);
|
104
|
UIkit.use(Svg);
|
105
|
UIkit.use(Icon);
|
106
|
UIkit.use(Switcher);
|
107
|
UIkit.use(Tab);
|
108
|
|
109
|
}
|