lemon-carpenter-66863
11/12/2021, 5:06 PMmysterious-toddler-20573
11/12/2021, 5:07 PMlemon-carpenter-66863
11/12/2021, 5:16 PMI created page transitions with a Javascript animation library which functions are triggered when the DOM settles (by means of a function, every animation "lives" in it's own function).Problem is, I have two seperate animations (one for page transitions and one for menu transitions). and they keep on interfering with each other... So basically: When I trigger a regular button, animation 1 triggers (a div obscures the page) at that point HTMX swaps the content and the div slides out of of view. With the menu, animation 2 triggers and it opens a fullscreen menu and when a button in the menu is pressed, HTMX swaps the content and the menu rolls upward revealing the page. Right now with your fix it is partially ok (as before they always triggered both when both were triggered once before). But it still breaks when the same animation is triggered multiple times in succession. Switching between them works OK now though.mysterious-toddler-20573
11/12/2021, 5:18 PMlemon-carpenter-66863
11/12/2021, 5:23 PMvar transitionpage = document.querySelector(".animation_veil");
var data = JSON.parse(transitionpage.getAttribute('data-pg-ia'));
function pagetranstion() {
pagetransitionEvent = htmx.on("htmx:afterSettle", function(evt) { pagetranstionout() });
pgia.play(transitionpage, 'page_transition_ease_in', data);
}
function pagetranstionout() {
setTimeout(function(){
pgia.play(transitionpage, 'page_transition_ease_out', data);
}, 350);
setTimeout(function(){
removeMenutransitionEventHandler();
}, 350);
}
function removePagetransitionHandler() {
htmx.off("htmx:afterSettle", pagetransitionEvent);
}
//menutransition functions
var menutransition = document.querySelector(".menu_hamburger_button");
//var data = JSON.parse(menutransition.getAttribute('data-pg-ia'));
function menutransition_function() {
menutransitionEvent = htmx.on("htmx:afterSettle", function(evt) { pgia.play(menutransition, 'menutransition'); });
setTimeout(function(){
removePagetransitionHandler();
}, 350);
}
function removeMenutransitionEventHandler() {
htmx.off("htmx:afterSettle", menutransitionEvent);
}
I tried hyperscript a while back (this: _=on htmx:afterSettle call doSomething()" but is seemed to have no effect...mysterious-toddler-20573
11/12/2021, 5:43 PMjs
htmx.on("htmx:afterSettle", ...)
that's going to be global for all requests. If you can target a specific element with the listener instead the two event handlers won't conflict.late-king-98305
11/12/2021, 5:44 PMcareful-room-54859
11/12/2021, 8:30 PMlemon-carpenter-66863
11/12/2021, 11:09 PMcareful-room-54859
11/13/2021, 12:06 AMactive flag from one element and add it to another based on the path perhaps? Has anyone done anything like this? Just struggling trying to coordinate the disparate actions.....mysterious-toddler-20573
11/13/2021, 12:32 AMmysterious-toddler-20573
11/13/2021, 12:32 AMcareful-room-54859
11/13/2021, 12:32 AMmysterious-toddler-20573
11/13/2021, 12:32 AMcareful-room-54859
11/13/2021, 12:33 AMmysterious-toddler-20573
11/13/2021, 12:33 AMcareful-room-54859
11/13/2021, 12:33 AMactive class but I can't see how you would only do that....mysterious-toddler-20573
11/13/2021, 12:33 AMcareful-room-54859
11/13/2021, 12:34 AMmysterious-toddler-20573
11/13/2021, 12:34 AMcareful-room-54859
11/13/2021, 12:34 AMcareful-room-54859
11/13/2021, 12:35 AMmysterious-toddler-20573
11/13/2021, 12:35 AMmysterious-toddler-20573
11/13/2021, 12:35 AMmysterious-toddler-20573
11/13/2021, 12:35 AMcareful-room-54859
11/13/2021, 12:36 AMcareful-room-54859
11/13/2021, 12:36 AMcareful-room-54859
11/13/2021, 12:36 AMmysterious-toddler-20573
11/13/2021, 12:37 AMhtml
<div _="on click take .active from <a/> in me for the event's target">
<a>breadcrumb 1</a>
<a>breadcrumb 2</a>
<a>breadcrumb 3</a>
...
</div>careful-room-54859
11/13/2021, 12:37 AM