Skip to content

Commit cd60461

Browse files
committed
feature(*): instance variable with library semver [closes #262]
1 parent 7e4649e commit cd60461

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

src/scrollreveal.js

+32-31
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,38 @@
2828
var sr
2929
var _requestAnimationFrame
3030

31+
function ScrollReveal (config) {
32+
// Support instantiation without the `new` keyword.
33+
if (typeof this === 'undefined' || Object.getPrototypeOf(this) !== ScrollReveal.prototype) {
34+
return new ScrollReveal(config)
35+
}
36+
37+
sr = this // Save reference to instance.
38+
sr.version = '3.1.5'
39+
sr.tools = new Tools() // *required utilities
40+
41+
if (sr.isSupported()) {
42+
sr.tools.extend(sr.defaults, config || {})
43+
44+
_resolveContainer(sr.defaults)
45+
46+
sr.store = {
47+
elements: {},
48+
containers: []
49+
}
50+
51+
sr.sequences = {}
52+
sr.history = []
53+
sr.uid = 0
54+
sr.initialized = false
55+
} else if (typeof console !== 'undefined' && console !== null) {
56+
// Note: IE9 only supports console if devtools are open.
57+
console.log('ScrollReveal is not supported in this browser.')
58+
}
59+
60+
return sr
61+
}
62+
3163
/**
3264
* Configuration
3365
* -------------
@@ -93,37 +125,6 @@
93125
afterReset: function (domEl) {}
94126
}
95127

96-
function ScrollReveal (config) {
97-
// Support instantiation without the `new` keyword.
98-
if (typeof this === 'undefined' || Object.getPrototypeOf(this) !== ScrollReveal.prototype) {
99-
return new ScrollReveal(config)
100-
}
101-
102-
sr = this // Save reference to instance.
103-
sr.tools = new Tools() // *required utilities
104-
105-
if (sr.isSupported()) {
106-
sr.tools.extend(sr.defaults, config || {})
107-
108-
_resolveContainer(sr.defaults)
109-
110-
sr.store = {
111-
elements: {},
112-
containers: []
113-
}
114-
115-
sr.sequences = {}
116-
sr.history = []
117-
sr.uid = 0
118-
sr.initialized = false
119-
} else if (typeof console !== 'undefined' && console !== null) {
120-
// Note: IE9 only supports console if devtools are open.
121-
console.log('ScrollReveal is not supported in this browser.')
122-
}
123-
124-
return sr
125-
}
126-
127128
/**
128129
* Check if client supports CSS Transform and CSS Transition.
129130
* @return {boolean}

0 commit comments

Comments
 (0)