Joined July 2013
·
Posted to
Did you know you can multithread in JavaScript?
over 1 year
ago
Nice read! Very well written... just posted something similar ... seems like you had been first :D Well played... well played.... always good to share the word of awesome new web features. :)
Posted to
JavaScript inheritance for Beginners
over 1 year
ago
Thank you! :)
Posted to
(Re)Learning Javascript the Right Way
over 1 year
ago
Nice one! Always good to keep own skills on track of time. However, instead of parseInt you can also use double not bitwise operator ~~. Its much faster than parseInt()
and with the same result, even without the second argument. :)
var base = Number(45.232);
console.log(parseInt(base)); // outputs 45
console.log(~~(base)); // also outputs 45
You can checkout a jsPerf comparison
Posted to
Gameloop - the correct way
over 1 year
ago
Thanks! But with the polyfill by Erik Moeller you're quite ready for older browsers without requestAnimationFrame and up to date browsers, as this includes an alternative setInterval
fallback. :)
// requestAnimationFrame polyfill by Erik Moeller
var lastTime = 0;
var vendors = ['webkit', 'moz'];
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)
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
Achievements
567 Karma
111,115 Total ProTip Views
Nephila Komaci
Have at least one original repos where PHP is the dominant language
Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos
Forked
Have a project valued enough to be forked by someone else
Charity
Fork and commit to someone's open source project in need
Cub
Have at least one original jQuery or Prototype open source repo
@vohof What exactly do you mean? Seems fine for me?