Skip to content

Commit 969e3bb

Browse files
author
Maksims Mihejevs
committed
history hashing
1 parent 9acbbaa commit 969e3bb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/index.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,10 @@ <h2>Mouse input</h2>
180180
frame.disabled = true;
181181
document.body.removeClass('preview');
182182
headerTitle.textContent = initialTitle;
183-
location.hash = '';
183+
location.hash = '#';
184184
}
185185

186-
// HISTORY
187-
window.addEventListener('hashchange', processLocation, false);
186+
var lastHash = null;
188187

189188
function processLocation(url) {
190189
if (location.hash && location.hash !== '#') {
@@ -195,13 +194,21 @@ <h2>Mouse input</h2>
195194
var title = element.querySelector('h2').textContent;
196195
var url = element.getAttribute('data-link');
197196
openExample(title, url);
197+
lastHash = true;
198198
return;
199199
}
200200
}
201-
closeExample();
201+
202+
if (lastHash) {
203+
closeExample();
204+
}
205+
lastHash = true;
202206
}
203207

204208
processLocation();
209+
210+
// HISTORY
211+
window.addEventListener('hashchange', processLocation, false);
205212
</script>
206213

207214
</body>

0 commit comments

Comments
 (0)