Skip to content

Instantly share code, notes, and snippets.

@erayarslan
Created October 27, 2016 01:29
Show Gist options
  • Select an option

  • Save erayarslan/39ef54c52ff50d4324df86f81c1dd1ea to your computer and use it in GitHub Desktop.

Select an option

Save erayarslan/39ef54c52ff50d4324df86f81c1dd1ea to your computer and use it in GitHub Desktop.
golden ratio calculator with hashchange event
<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