Created
October 27, 2016 01:29
-
-
Save erayarslan/39ef54c52ff50d4324df86f81c1dd1ea to your computer and use it in GitHub Desktop.
golden ratio calculator with hashchange event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>golden ratio</title> | |
| </head> | |
| <body> | |
| <div id="point"></div> | |
| <script> | |
| var go = 1; | |
| var timeout = 100; // ms | |
| var el = document.getElementById("point"); | |
| var update = function (point) { | |
| document.title = point; | |
| location.hash = point; | |
| el.innerText = point; | |
| }; | |
| window.addEventListener("hashchange", function (e) { | |
| setTimeout(function () { | |
| update(1 + (1 / parseFloat(location.hash.substr(1)))); | |
| }, 250); | |
| }, false); | |
| location.hash = go; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment