These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:03 pm Advanced search

javascript

Here you can discuss stuff that doesn't fit elsewhere; anything you want really.

javascript

Postby zottona » Wed Oct 21, 2009 11:10 am

How to make something shake with javascript? I want to make something shake when its clicked on with javascript and don't know how to do that.
zottona
<h6>
 
Posts: 1
Joined: Wed Oct 14, 2009 10:48 am

Postby JAB Creations » Wed Oct 21, 2009 1:33 pm

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. I suggest you visit your preferred search engine and type "JavaScript shake" as you will see plenty of existing demos.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby zcorpan » Sun Oct 25, 2009 10:43 pm

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.
Nonetheless it's perfectly fine to ask non-HTML5 questions in off topic. :)
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby JAB Creations » Sun Oct 25, 2009 11:59 pm

...that's because I moved it to the off-topic forum. :roll:

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.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby zcorpan » Mon Oct 26, 2009 8:34 am

JAB Creations wrote:...that's because I moved it to the off-topic forum. :roll:
Heh, yeah ok.

JAB 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.
Not a loop but an interval; maybe something like
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. :)
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby Den2501 » Wed Sep 08, 2010 3:31 pm

zcorpan wrote:
JAB Creations wrote:...that's because I moved it to the off-topic forum. :roll:
Heh, yeah ok.

JAB 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.
Not a loop but an interval; maybe something like
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. :)


Hhhmmm... A tricky one. I am just starting to study flash/cs4 and I still find everything to be a bit difficult.

I hope I can make use of the codes you have provided on the menus that I am creating for my website...will post the link here as soon as I am done with it.
Den2501
<h6>
 
Posts: 1
Joined: Wed Sep 08, 2010 3:23 pm
Location: Germany

Postby zcorpan » Wed Sep 08, 2010 5:22 pm

zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to Off Topic

Who is online

Users browsing this forum: No registered users and 1 guest