-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (49 loc) · 1.07 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
54
55
56
57
58
59
60
61
var OnAppear = require('on-appear');
var extend = function(obj, props) {
var newObj = Object.create(obj);
for(var prop in props) {
if(props.hasOwnProperty(prop)) {
newObj[prop] = props[prop];
}
}
return newObj;
};
var AppearAnimation = {
delay: 0,
offset: 0,
instances: [],
elements: [],
create: function(obj) {
return extend(this, obj);
},
init: function() {
for (var i = 0; i < this.elements.length; i++) {
var el = this.elements[i];
this.register(el);
}
},
prepare: function(el, instance) {
// To implement
},
run: function(el, instance) {
// To implement
},
register: function(el) {
var _this = this;
var instance = new OnAppear(el, {
delay: this.delay,
offset: this.offset,
callback: function() {
_this.run(el, this);
}
});
this.prepare(el, instance);
this.instances.push(instance);
},
destroy: function() {
for (var i = 0; i < this.instances.length; i++) {
this.instances[i].destroy();
}
}
};
module.exports = AppearAnimation;