Lab5 - JQuery Animation

link to Lab5

In this lab, we were assigned the task of creating this 2d square along with buttons. These buttons would include commands such as go left, go right, go up, go down, etc., but what made this special was that the code behind the animation was that we used JQuery, specifically the "animate" tag. What this tag does is quite self-explanatory in the name; however, the actual variable being changed is the CSS of the element. For example, to animate the box going left it would look like this:

function left(){
  $("#box").animate({left: "-=250px"});
  $("#box").animate({left: "+=250px"});
 }

The code in the curly bracket is CSS and is using the left tag and modifying it. This is what makes the animate tag work. This was repeated with other CSS tags such as right, opacity, height, etc.

Comments

Popular posts from this blog

Lab 23-2: Type Ahead

WBL Workshop 2

Lab7 - Simple Accordion