0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

expose demo instance externally

This commit is contained in:
liabru 2016-01-14 23:25:16 +00:00
parent 1a55259ba7
commit a9122ed488
2 changed files with 12 additions and 4 deletions

View file

@ -26,11 +26,11 @@
<script type="text/javascript" src="./js/Examples.js"></script> <script type="text/javascript" src="./js/Examples.js"></script>
<script type="text/javascript" src="./js/Demo.js"></script> <script type="text/javascript" src="./js/Demo.js"></script>
<title>Matter.js Demo (Edge Build)</title> <title>Matter.js Demo</title>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h1>Matter.js Demo (Edge Build)</h1> <h1>Matter.js Demo</h1>
<p class="nav nav-links"><a href="./mobile.html">Mobile Demo</a> <span class="nav-sep">&middot;</span> <a href="http://brm.io/matter-js/">Project page</a> <span class="nav-sep">&middot;</span> <a href="https://github.com/liabru/matter-js">GitHub</a> <span class="nav-sep">&middot;</span> <a href="http://twitter.com/liabru">@liabru</a></p> <p class="nav nav-links"><a href="./mobile.html">Mobile Demo</a> <span class="nav-sep">&middot;</span> <a href="http://brm.io/matter-js/">Project page</a> <span class="nav-sep">&middot;</span> <a href="https://github.com/liabru/matter-js">GitHub</a> <span class="nav-sep">&middot;</span> <a href="http://twitter.com/liabru">@liabru</a></p>
<div class="controls-container"> <div class="controls-container">
<select id="demo-select"> <select id="demo-select">

View file

@ -53,6 +53,7 @@
Demo.init = function() { Demo.init = function() {
var demo = Demo.create(); var demo = Demo.create();
Matter.Demo._demo = demo;
// get container element for the canvas // get container element for the canvas
demo.container = document.getElementById('canvas-container'); demo.container = document.getElementById('canvas-container');
@ -193,7 +194,10 @@
demoSelect.addEventListener('change', function(e) { demoSelect.addEventListener('change', function(e) {
Demo.reset(demo); Demo.reset(demo);
Demo.setScene(demo,demo.sceneName = e.target.value); Demo.setScene(demo,demo.sceneName = e.target.value);
Gui.update(demo.gui);
if (demo.gui) {
Gui.update(demo.gui);
}
var scrollY = window.scrollY; var scrollY = window.scrollY;
window.location.hash = demo.sceneName; window.location.hash = demo.sceneName;
@ -204,7 +208,11 @@
demoReset.addEventListener('click', function(e) { demoReset.addEventListener('click', function(e) {
Demo.reset(demo); Demo.reset(demo);
Demo.setScene(demo, demo.sceneName); Demo.setScene(demo, demo.sceneName);
Gui.update(demo.gui);
if (demo.gui) {
Gui.update(demo.gui);
}
Demo.setUpdateSourceLink(demo.sceneName); Demo.setUpdateSourceLink(demo.sceneName);
}); });
}; };