Add polyfill
Browse files
assets/scripts/src/polyfill.js
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Source: https://gist.github.com/paulirish/1579671
|
2 |
+
(function () {
|
3 |
+
let lastTime = 0;
|
4 |
+
const vendors = ['ms', 'moz', 'webkit', 'o'];
|
5 |
+
|
6 |
+
for (let x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
7 |
+
window.requestAnimationFrame = window[`${vendors[x]}RequestAnimationFrame`];
|
8 |
+
window.cancelAnimationFrame = window[`${vendors[x]}CancelAnimationFrame`] || window[`${vendors[x]}CancelRequestAnimationFrame`];
|
9 |
+
}
|
10 |
+
|
11 |
+
if (!window.requestAnimationFrame) {
|
12 |
+
window.requestAnimationFrame = function (callback) {
|
13 |
+
const currTime = new Date().getTime();
|
14 |
+
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
15 |
+
const id = window.setTimeout(
|
16 |
+
() => { callback(currTime + timeToCall); },
|
17 |
+
timeToCall,
|
18 |
+
);
|
19 |
+
lastTime = currTime + timeToCall;
|
20 |
+
return id;
|
21 |
+
};
|
22 |
+
}
|
23 |
+
|
24 |
+
if (!window.cancelAnimationFrame) {
|
25 |
+
window.cancelAnimationFrame = function (id) {
|
26 |
+
clearTimeout(id);
|
27 |
+
};
|
28 |
+
}
|
29 |
+
}());
|
assets/scripts/src/sholo.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import Overlay from './overlay';
|
2 |
import Element from './element';
|
3 |
-
|
4 |
|
5 |
/**
|
6 |
* Plugin class that drives the plugin
|
|
|
1 |
import Overlay from './overlay';
|
2 |
import Element from './element';
|
3 |
+
import './polyfill';
|
4 |
|
5 |
/**
|
6 |
* Plugin class that drives the plugin
|