-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·53 lines (43 loc) · 1.02 KB
/
index.js
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
46
47
48
49
50
51
52
53
const sr = require('scrollreveal')();
function generateOptions(bindingValue, bindingModifiers) {
const options = bindingValue || {};
if (bindingModifiers) {
if (bindingModifiers.reset) {
options.reset = true;
}
if (bindingModifiers.nomobile) {
options.mobile = false;
}
}
return options;
}
const VueScrollReveal = {
install(Vue) {
Vue.directive('scroll-reveal', {
inserted: (el, binding) => {
const options = generateOptions(binding.value);
sr.reveal(el, options);
},
update: (el, binding) => {
if (binding.value != binding.oldValue) {
const options = generateOptions(binding.value, binding.modifiers);
sr.reveal(el, options);
}
},
});
const $sr = {
isSupported() {
return sr.isSupported();
},
sync() {
sr.sync();
},
};
Object.defineProperty(Vue.prototype, '$sr', {
get() {
return $sr;
},
});
},
};
export default VueScrollReveal;