Created
September 1, 2015 03:26
-
-
Save fchasen/10aa332197c2da0cabe4 to your computer and use it in GitHub Desktop.
Hash Change
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
// From: https://github.com/futurepress/epub.js/blob/master/reader_src/controllers/controls_controller.js | |
var hashChanged = function(){ | |
var hash = window.location.hash.slice(1); | |
book.goto(hash); | |
}; | |
book.on('renderer:locationChanged', function(cfi){ | |
var cfiFragment = "#" + cfi; | |
// Update the History Location | |
if(window.location.hash != cfiFragment) { | |
// Add CFI fragment to the history | |
history.pushState({}, '', cfiFragment); | |
} | |
}); | |
window.addEventListener("hashchange", hashChanged.bind(this), false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment