Skip to content
Browse files

Turn this example into a demo for pluggable design. Put "3d" in

window.location to see a simple 3d effect. Like:

    chase2.html?3d


git-svn-id: http://code.handlino.com/svn/Ebisu/javascript@37 b19cb30a-9f2e-4084-8847-5e1a13269302
  • Loading branch information...
1 parent 221c335 commit bf69b1dbb0c911121f3129384f34110ee8a3e655 @gugod gugod committed Oct 23, 2007
Showing with 34 additions and 10 deletions.
  1. +10 −0 examples/chase2-3d.js
  2. +11 −9 examples/chase2.html
  3. +4 −1 examples/chase2.js
  4. +9 −0 examples/field.css
View
10 examples/chase2-3d.js
@@ -0,0 +1,10 @@
+$(document).ready(function($) {
+ for(var i = 0; i < 10; i++) {
+ Ebisu("mouse near " + i).to( jQuery("#chaser-" + i)[0] ).attach(
+ function(x, y) {
+ var r = Math.sqrt(3 * y);
+ $(this).css({ width: r, height: r });
+ }
+ )
+ }
+});
View
20 examples/chase2.html
@@ -6,12 +6,23 @@
<script src="field.js"></script>
<script src="chase2.js"></script>
+ <script type="text/javascript">
+ if(window.location.toString().match(/3d/)) {
+ document.write("<script src='chase2-3d.js'\>\<\/script>");
+ }
+ </script>
+
+
<title>Chase</title>
<style type="text/css">
+
+@import "field.css";
+
body {
background:black;
color:white;
}
+
.chaser {
-moz-border-radius: 100px;
width: 10px;
@@ -21,15 +32,6 @@
color:red;
z-index: 5;
}
-#field {
- position: absolute;
- top: 0;
- left: 0;
- z-index: 10;
- overflow: hidden;
- width: 100%;
- height: 100%;
-};
</style>
</head>
View
5 examples/chase2.js
@@ -14,7 +14,10 @@ $(document).ready(function($) {
var v = 1/(1+i);
var dx = loc_x - x;
var dy = loc_y - y;
- $(this).css({ left: x + dx * v, top: y + dy * v })
+
+ x = x + dx * v;
+ y = y + dy * v;
+ $(this).css({ left: x, top: y});
}
Ebisu("mouse near").attach(function(x, y) {
View
9 examples/field.css
@@ -0,0 +1,9 @@
+#field {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 10;
+ overflow: hidden;
+ width: 100%;
+ height: 100%;
+};

0 comments on commit bf69b1d

Please sign in to comment.
Something went wrong with that request. Please try again.