Fix for event listeners being duplicated on source change
This commit is contained in:
@ -33,6 +33,10 @@ shr.setup({
|
||||
buttons[i].addEventListener('click', newSource);
|
||||
}
|
||||
|
||||
window.addEventListener('popstate', function(event) {
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
function toggleClass(element, className, state) {
|
||||
if (element) {
|
||||
if (element.classList) {
|
||||
@ -113,6 +117,10 @@ shr.setup({
|
||||
break;
|
||||
}
|
||||
|
||||
if (window.history && window.history.pushState) {
|
||||
history.pushState({ 'type': type }, '', '#' + type);
|
||||
}
|
||||
|
||||
for (var x = buttons.length - 1; x >= 0; x--) {
|
||||
toggleClass(buttons[x].parentElement, 'active', false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user