-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.html
157 lines (142 loc) · 4.44 KB
/
demo.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body {
margin: 0;
background-color: #343e48;
font-family: Arial;
font-size: 14px;
}
#canvas-container {
width: 640px;
height: 480px;
margin: auto;
}
#demo-list {
background-color: #fff;
position: fixed;
margin: 0;
padding: 10px 0;
left: 0;
top: 10px;
list-style: none;
line-height: 20px;
border-radius: 4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
box-shadow: 0 5px 10px rgba(255, 255, 255, 0.2);
}
#demo-list .header {
font-size: 18px;
font-weight: bold;
line-height: 24px;
border-bottom: 1px solid #ccc;
margin-bottom: 4px;
}
#demo-list a {
text-decoration: none;
color: #0088cc;
display: block;
padding: 2px 30px 2px 20px;
}
#demo-list a:hover {
background-color: #0088cc;
color: #ffffff;
}
#demo-list a.current {
background-color: #0088cc;
color: #ffffff;
opacity: .5;
}
</style>
<script>
var NDEBUG = true
</script>
</head>
<body>
<ul id="demo-list" data-toggle-state=1>
<li class="header"><a href="index.html">Chipmunk JS</a></li>
</ul>
<div id="canvas-container">
<canvas id="canvas" width="640" height="480" tabindex="1"></canvas>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/stats.js/r11/Stats.js"></script>
<script src="cp.js"></script>
<script src="demo/Demo.js"></script>
<script src="demo/Renderer.js"></script>
<script src="demo/Base.js"></script>
<script src="demo/Tumble.js"></script>
<script src="demo/PyramidStack.js"></script>
<script src="demo/Convex.js"></script>
<script src="demo/Query.js"></script>
<script src="demo/Crane.js"></script>
<script src="demo/PyramidTopple.js"></script>
<script src="demo/Sticky.js"></script>
<script src="demo/TheoJansen.js"></script>
<script src="demo/Springies.js"></script>
<script src="demo/ContactGraph.js"></script>
<script src="demo/Buoyancy.js"></script>
<script src="demo/Pump.js"></script>
<script src="demo/LogoSmash.js"></script>
<script src="demo/OneWay.js"></script>
<script src="demo/Planet.js"></script>
<script src="demo/ContactPoints.js"></script>
<script src="demo/GJK.js"></script>
<script src="demo/Joints.js"></script>
<script src="demo/Player.js"></script>
<script src="demo/Plink.js"></script>
<script src="demo/Shatter.js"></script>
<script src="demo/Slice.js"></script>
<script src="demo/Smooth.js"></script>
<script src="demo/Tank.js"></script>
<script src="demo/Unicycle.js"></script>
<script src="demo/Chains.js"></script>
<script>
jQuery(function() {
var $demoList = $('#demo-list')
function toggleDemoList(state) {
state || (state = !$demoList.data('toggle-state'))
$demoList.data('toggle-state', state)
var left = state? 0 : $demoList.width() - 20
$demoList.stop().animate({left: -left})
}
for (var i = 0; i < Demo.demoList.length; i++) {
$demoList.append('<li><a href="#' + i + '" data-index="' + i + '">' + Demo.demoList[i].prototype.name + '</a></li>')
}
var hideDemoListTimeoutId = setTimeout(toggleDemoList, 3000)
$demoList.on({
mouseenter: function() {
clearTimeout(hideDemoListTimeoutId)
toggleDemoList(true)
}
,mouseleave: function() {
clearTimeout(hideDemoListTimeoutId)
hideDemoListTimeoutId = setTimeout(function() {
toggleDemoList(false)
}, 1000)
}
})
$demoList.on('click', 'a[data-index]', function(e) {
e.stopPropagation()
var index = $(this).data('index')
Demo.runDemo(index)
$demoList.find('a.current').removeClass('current')
$(this).addClass('current')
$('#canvas').focus()
})
Demo.run();
var demoIndex = parseInt(location.hash.substr(1))
if (isNaN(demoIndex)) {
demoIndex = 0
}
Demo.runDemo(demoIndex);
$demoList.find('a[data-index=' + demoIndex + ']').addClass('current')
$('#canvas').focus()
})
</script>
</body>
</html>