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 to fire events programatically | |
* on DOM elements | |
* | |
* Example: | |
* var domEl = document.getElementById('elementId') | |
* fireEvent(domEl, 'mouseover') | |
* | |
* @param {Node} el DOM element | |
* @param {String} Event name as String |
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
const easeInQuad = (t, b, c, d) => { | |
return c * (t /= d) * t + b; | |
} | |
const requestAnimFrame = (() => { | |
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; | |
})(); | |
export const scrollElementLeftTo = (element, to, duration = 400, callback) => { | |
const move = (amount) => { |
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
const easeInQuad = (t, b, c, d) => { | |
return c * (t /= d) * t + b; | |
} | |
const requestAnimFrame = (() => { | |
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; | |
})(); | |
export const scrollBodyTo = (to, duration = 400, callback) => { | |
const move = (amount) => { |
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
let imgs = ['image1.jpg', 'image2.jpg'] | |
let convertedImages = []; | |
let worker = new Worker('worker.js'); | |
worker.addEventListener('message', function(event) { | |
convertedImages = event.data; | |
}) |
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 toDataUrl(src, type, callback) { | |
const img = new Image(); | |
img.onload = function() { | |
const canvas = document.createElement('canvas'); | |
const ctx = canvas.getContext('2d'); | |
canvas.height = this.height; | |
canvas.width = this.width; | |
ctx.drawImage(this, 0, 0); | |
callback(canvas.toDataURL(type)); |
NewerOlder