1
Fork 0

Only setup event handlers once document is ready

This commit is contained in:
Jake Howard 2022-01-14 19:05:36 +00:00
parent 81642bc854
commit 9ad27215ab
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -58,14 +58,13 @@ $(document).ready(function() {
endAudio: '/audio/ding.mp3', endAudio: '/audio/ding.mp3',
preloadAudio: false, preloadAudio: false,
}); });
});
$('#scroll-top').on('click', function() { $('#scroll-top').on('click', function() {
scrollTo(0); scrollTo(0);
resetHash(); resetHash();
}); });
$('a[href^="#"]').on('click', function(event) { $('a[href^="#"]').on('click', function(event) {
if (this.dataset.noPreventDefault === undefined) { if (this.dataset.noPreventDefault === undefined) {
event.preventDefault(); event.preventDefault();
resetHash(); resetHash();
@ -74,9 +73,9 @@ $('a[href^="#"]').on('click', function(event) {
if (target.length) { if (target.length) {
scrollTo(target.offset().top); scrollTo(target.offset().top);
} }
}); });
$('.content img').on('click', function(event) { $('.content img').on('click', function(event) {
event.preventDefault(); event.preventDefault();
const lightbox = $('#lightbox-modal'); const lightbox = $('#lightbox-modal');
lightbox.find('img').remove(); lightbox.find('img').remove();
@ -84,4 +83,5 @@ $('.content img').on('click', function(event) {
.clone() .clone()
.appendTo(lightbox.find('.modal-content')); .appendTo(lightbox.find('.modal-content'));
lightbox.modal(); lightbox.modal();
});
}); });