Skip to content

Instantly share code, notes, and snippets.

View yoannmoinet's full-sized avatar
🐶
DX and Tooling

Yoann Moinet yoannmoinet

🐶
DX and Tooling
View GitHub Profile
@yoannmoinet
yoannmoinet / setCSS.js
Created January 11, 2013 14:33
Set css vendor specific.
function setCSS(prop,value,css){
var ar = ["-webkit-","-o-","-moz-","-ms-","-khtml-",""];
if(css === undefined)
{
css = {};
}
for(var i = 0, max = ar.length; i<max; i+=1)
{
css[ar[i]+prop] = value;
}
@yoannmoinet
yoannmoinet / scrollEvt.js
Created January 10, 2013 22:34
Cross browser scroll event handler, with a consistant delta.
var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
if (document.attachEvent)
document.attachEvent("on"+mousewheelevt, function(e){scroller(e)});
else if (document.addEventListener)
document.addEventListener(mousewheelevt, function(e){scroller(e)},false);
function scroller(evt)
{
//Guess the delta.
@yoannmoinet
yoannmoinet / requestAnimationFrame.js
Created January 10, 2013 21:47
Request Animation Frame polyfill
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)