forked from EmilStenstrom/jQuery-animate_from_to
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_usage.html
61 lines (53 loc) · 1.87 KB
/
example_usage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head><title>Sample usage for the Animate From To-plugin</title></head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="jquery.animate_from_to-1.0.js"></script>
<script>
$(document).ready(function(){
$("#button1").click(function(){
// Animate one element to another – bare bones version:
$("#prod_123").animate_from_to("#cart");
// May also be constructed as:
// $.animate_from_to("#prod_123", "#cart");
})
$("#button2").click(function(){
$("#prod_123").animate_from_to('#cart', {
pixels_per_second: 200
});
// Or :
/*
$.animate_from_to("#prod_123", "#cart", {
pixels_per_second: 200
});
*/
})
$("#button3").click(function(){
$("#prod_123").animate_from_to('#cart', {
pixels_per_second: 200,
initial_css: {
'background': 'blue'
}
});
})
$("#button4").click(function(){
$("#prod_123").animate_from_to('#cart', {
callback: function(){ alert('Animation done') },
});
})
});
</script>
<span id="cart">
My shopping cart
</span>
<div id="prod_123" style="height: 100px; width:300px; margin-top: 300px; background: pink">
<form onsubmit="return false;">
<button type="submit" id="button1">Add to cart (default)</button>
<button type="submit" id="button2">Add to cart (slow)</button>
<button type="submit" id="button3">Add to cart (slow, blue)</button>
<button type="submit" id="button4">Add to cart (callback)</button>
</form>
</div>
</body>
</html>