projects
/
heroik.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f3c5487
)
Consistent fragment target behavior.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Fri, 29 Aug 2014 16:24:17 +0000
(18:24 +0200)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Fri, 29 Aug 2014 16:24:17 +0000
(18:24 +0200)
heroik.js
patch
|
blob
|
history
diff --git
a/heroik.js
b/heroik.js
index
bca710e
..
88b1d32
100644
(file)
--- a/
heroik.js
+++ b/
heroik.js
@@
-30,11
+30,7
@@
function scrollToId (id) {
function open (event) {
var href = this.href;
var target = this.target === "_parent" ? window.parent : window;
function open (event) {
var href = this.href;
var target = this.target === "_parent" ? window.parent : window;
-
- if (this.getAttribute('href')[0] === "#")
- scrollToId(this.getAttribute('href').slice(1));
- else
- target.location.href = this.href;
+ target.location.href = this.href;
event.preventDefault();
}
event.preventDefault();
}
@@
-44,6
+40,10
@@
window.addEventListener('load', function () {
scrollToId(location.hash.slice(1));
});
scrollToId(location.hash.slice(1));
});
+window.addEventListener('hashchange', function () {
+ scrollToId(location.hash.slice(1));
+});
+
window.addEventListener('DOMContentLoaded', function () {
if (navigator.standalone)
document.body.className += ' standalone';
window.addEventListener('DOMContentLoaded', function () {
if (navigator.standalone)
document.body.className += ' standalone';