19 |
20 |
1
21 |
22 |
Create a new basic animation
23 |
24 |
Exercise 1 - Moving Right
25 |
26 |
Now let's code some animation out! In the 'Try It
27 | Yourself' block, you should see a default div block with class named 'test'
28 | and ID named 'a' coloured in red. If you don't like the colour, you can
29 | always change it around. Click on 'Update' when you have finished typing in
30 | your code.
31 |
Now we want to make the red rounded
32 | rectangle move to 300px from left for 2 seconds. We should do the
33 | following:
34 |
35 |
new Animation(document.querySelector("#a"), {left:
36 | "300px"}, 2);
37 |
38 |
Show Solution
39 |
40 | new Animation(document.querySelector("#a"), {left: "300px"}, 2);
41 |
42 |
43 |
44 |
45 |
46 | 'new Animation()'
creates a new animation object.
47 | -
48 |
'document.querySelector("#a")'
is a DOM method which
49 | gets the element with id equals to 'a' from the HTML file. You
50 | can always use 'document.getElementById("a")'
which
51 | would result the same thing. Since we have defined its class
52 | name as well, we can also select it using
53 | 'document.querySelector(".test")'.
54 |
55 | '{left: "300px"}'
is the effects of the animation.
56 | In this case we are letting it move to 300px from left.
57 | '2'
will set the duration of the animation to
58 | 2 seconds. The bigger the number, the slower the animation
59 | speed and vice versa.
60 |
61 |
62 |
--------------------------------------------------------------------------------
/tutorial/iframe-contents.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
23 |
24 |
3
25 |
26 |
Parallel Animation Group
27 |
28 |
Exercise 1 - Make a Parallel Group
29 |
30 |
Groupings are important so let's
31 | get started on the exercise
32 |
33 |
In this exercise, create a parallel group
34 | of animation that has 3 different animations. Each children should run 300px,
35 | 500px, 700px from top respectively for 5 seconds.
36 |
37 |
Hint: you should first create the children then
38 | include the children into the group. You might also need to create
39 | more animation divs in the html section and change their colour
40 | depends on your preferences.
41 |
42 |
Show Solution
43 |
44 | var A = new Animation(document.querySelector("#a"),
45 | {top: "300px"}, 5);
46 | var B = new Animation(document.querySelector("#b"),
47 | {top: "500px"}, 5);
48 | var C = new Animation(document.querySelector("#c"),
49 | {top: "700px"}, 5);
50 | new AnimationGroup([A, B, C]);
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/tutorial/sample-tutorial.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |