This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function scrollControl() { | |
| // left: 37, up: 38, right: 39, down: 40, | |
| // spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36 | |
| var keys = {37: 1, 38: 1, 39: 1, 40: 1} | |
| function preventDefault(e){ | |
| e.preventDefault() | |
| e.returnValue = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getFrameRate(ms) { | |
| var i = -1 | |
| var run = true | |
| function tick() { | |
| if (run === false) {return} | |
| i++ | |
| window.requestAnimationFrame(tick) | |
| } | |
| return new Promise(function(resolve){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function flatten(arr) { | |
| var ans = [] | |
| arr.forEach(function(ar){ | |
| if ( Array.isArray(ar) ) { ans = ans.concat( flatten(ar) ) } | |
| else { ans.push(ar) } | |
| }) | |
| return ans | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var get = function get(url) { | |
| return promise = new Promise(function(done, reject) { | |
| var req = new XMLHttpRequest() | |
| req.onload = function() { | |
| done(req.response) | |
| }; | |
| req.onerror = function(e) { | |
| reject(e) | |
| } | |
| req.open('get', url, true); |