html - animate menu: shall I use canvas or javascript? -


i must animate main menu links ( us, contact, etc) have specific graphics (i using anchor background image class). i'm wondering if canvas best way animate specific div (my menu). want move 100px upward/downwards after being clicked. example: click "projects", anchor (with image) moved 100 pixels down. when click "about us", "projects" link moved (at it's original position), , "about us" moved down 100px.

is canvas right way it? use css3 transitions/animate ie9 not supported. want ie9 able render site correctly.

shall use canvas or kind of javascript plugin this? ( use plain javascript relative/absolute positioning keeps changing top pixels, don't result of it). used plain javascript this:

my menu:

 <div id="menu">    <ul class="nav">         <li><a href="#" class="projects" id="projects" onclick="move()"></a>         </li>          <li><a href="#" class="aboutus"></a>         </li>          <li><a href="#" class="contact"></a>         </li>    </ul> 

my css:

 a.projects   {      width: 184px;      height: 32px;      background: url('css-images/projects.png') no-repeat;          position: absolute;  } #menu {     position:relative; } 

my javascript:

 function move(){      var proj = document.getelementbyid("projects");      var count = 0;      var id  = setinterval(loop, 30);       function loop(){          proj.style.top = count + "px";           var max = 100;          count+=10;          if(count >= max){         clearinterval(id);          }      }  } 

go jquery's animate() function if broad browser support required. if not, use css3 transitions.

if you're not concerned how animations long they're equivalent, leverage modernizr deliver css3 animations browsers support them , jquery animations don't.

it's worth nothing jquery's animate() function could natively deliver css3 animations eligible browsers, jquery's developers haven't yet implemented this. because browsers still implement css3 transitions varying degrees of success, whereas jquery geared towards keeping things consistent.

canvas isn't appropriate use case imo due abstraction semantic elements.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -