It is currently Sat Dec 02, 2017 4:03 pm Advanced search
Nonetheless it's perfectly fine to ask non-HTML5 questions in off topic.JAB Creations wrote:This forum is intended for discussion in regards to the new HTML5 standard; it is not a web programming forum intended for applicable use of existing standards.
Heh, yeah ok.JAB Creations wrote:...that's because I moved it to the off-topic forum.
Not a loop but an interval; maybe something likeJAB Creations wrote:I think it'd probably be a for loop mixed with styling however I've never bothered trying to do animations with JavaScript...or at least not yet.
var interval;
function startShake(elm) {
elm.style.position = 'relative';
interval = setInterval(function(elm) {
// change style.top and style.left to a random number between +- some pixels
}, 15);
}
function stopShake(elm) {
elm.style.position = 'static';
clearInterval(interval);
}
zcorpan wrote:Heh, yeah ok.JAB Creations wrote:...that's because I moved it to the off-topic forum.Not a loop but an interval; maybe something likeJAB Creations wrote:I think it'd probably be a for loop mixed with styling however I've never bothered trying to do animations with JavaScript...or at least not yet.
- Code: Select all
var interval;
function startShake(elm) {
elm.style.position = 'relative';
interval = setInterval(function(elm) {
// change style.top and style.left to a random number between +- some pixels
}, 15);
}
function stopShake(elm) {
elm.style.position = 'static';
clearInterval(interval);
}
Maybe add some CSS3 transitions to make it smooth; I'll leave that as an exercise to the reader.
Users browsing this forum: No registered users and 1 guest