Skip to content

Commit

Permalink
Adding latest updates to static main
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea committed Sep 29, 2023
1 parent ab80f8d commit 6e820a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 9 additions & 6 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,23 @@ document.addEventListener('htmx:afterSwap', function(evt) {
loadGsapAnimations();
createRadialBackgrounds();
window.dispatchEvent(new CustomEvent('set-route', { detail: { route: evt.detail.pathInfo.requestPath } }));
// updateTOC();
}, 10);
});

// document.addEventListener('htmx:afterSettle', function(evt) {
// setTimeout(function(){
// updateTOC();
// }, 10);
// });
document.addEventListener('htmx:afterSettle', function(evt) {
setTimeout(function(){
updateTOC();
}, 500);
});



function updateTOC(){
if(document.getElementById('table-of-contents')){
window.dispatchEvent(new CustomEvent('set-toc', { detail: { toc: JSON.parse(localStorage.getItem('toc')) } }));
setTimeout(function(){
window.dispatchEvent(new CustomEvent('set-toc', { detail: { toc: window.toc } }));
});
}
}

Expand Down
12 changes: 6 additions & 6 deletions layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@

<script src="{ url('/assets/js/main.js') }"></script>
<script>
window.addEventListener('static:content', function(evt) {
console.log('entered');
alert('got');
console.log(JSON.parse(evt.detail.toc));
window.dispatchEvent(new CustomEvent('set-toc', { detail: { toc: JSON.parse(evt.detail.toc) } }));
});
// window.addEventListener('static:content', function(evt) {
// console.log('entered');
// alert('got');
// console.log(JSON.parse(evt.detail.toc));
// window.dispatchEvent(new CustomEvent('set-toc', { detail: { toc: JSON.parse(evt.detail.toc) } }));
// });
</script>
</body>
</html>

0 comments on commit 6e820a2

Please sign in to comment.