Skip to content

Instantly share code, notes, and snippets.

@mattetti
Created November 21, 2012 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattetti/4123564 to your computer and use it in GitHub Desktop.
Save mattetti/4123564 to your computer and use it in GitHub Desktop.
bonsai.js bug reduction - running this script many times in a browser will behave differently
<!doctype html>
<html lang="en" class=" -webkit-">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0;">
<title>Demo</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bonsai/0.4.1/bonsai.min.js"></script>
</head>
<body>
<div id="movie1"></div>
<div id="movie2"></div>
</body>
<script>
var movie = bonsai.run(document.getElementById('movie1'), {
code: function() {
stage.on('message', function(data) {
new Rect(10, 10, 100, 100)
.fill('yellow')
.stroke('#f00', 2)
.addTo(stage);
});
},
width: 400,
height: 400,
});
var movie2 = bonsai.run(document.getElementById('movie2'), {
code: function(){},
width: 400,
height: 400,
});
movie2.on('load', function() {
movie.sendMessage({ foo: "bar" });
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment