mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-03-13 18:08:10 +00:00
added view transition test
This commit is contained in:
parent
fd349a3852
commit
2edc7a923b
@ -1161,7 +1161,6 @@ var htmx = (() => {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - did we punt on other folks inserting scripts?
|
||||
__processScripts(container) {
|
||||
let scripts = container.matches?.('script') ? [container] : container.querySelectorAll('script');
|
||||
for (let oldScript of scripts) {
|
||||
@ -2006,7 +2005,10 @@ var htmx = (() => {
|
||||
|
||||
try {
|
||||
if (document.startViewTransition) {
|
||||
await document.startViewTransition(task).finished;
|
||||
let finished = document.startViewTransition(task).finished;
|
||||
this.__trigger(document, "htmx:before:viewTransition", {task, finished})
|
||||
await finished;
|
||||
this.__trigger(document, "htmx:after:viewTransition", {task})
|
||||
} else {
|
||||
task();
|
||||
}
|
||||
|
||||
@ -259,4 +259,24 @@ describe('swap() unit tests', function() {
|
||||
triggered.should.be.true;
|
||||
})
|
||||
|
||||
it('triggers view transition events with transition:true', async function () {
|
||||
if (!document.startViewTransition) {
|
||||
this.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
let beforeTriggered = false;
|
||||
let afterTriggered = false;
|
||||
htmx.on('htmx:before:viewTransition', () => {
|
||||
beforeTriggered = true;
|
||||
});
|
||||
htmx.on('htmx:after:viewTransition', () => {
|
||||
afterTriggered = true;
|
||||
});
|
||||
|
||||
await htmx.swap({"target":"#test-playground", "text":"<div id='d1'>Content</div>", "transition":true})
|
||||
beforeTriggered.should.be.true;
|
||||
afterTriggered.should.be.true;
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user