Skip to content

Commit bb4bf30

Browse files
committed
Fix view transitions
1 parent 881ba29 commit bb4bf30

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

src/webflo-runtime/webflo-client/DeviceViewport.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ export class DeviceViewport {
5858
return el;
5959
}
6060

61-
#scheduleRender() {
61+
#scheduleRender(lag = 0) {
6262
if (this.#timer) return;
63-
this.#timer = requestAnimationFrame(() => {
64-
this.#render();
65-
this.#timer = null;
66-
});
63+
const exec = () => {
64+
this.#timer = requestAnimationFrame(() => {
65+
this.#render();
66+
this.#timer = null;
67+
});
68+
};
69+
if (!lag) return exec();
70+
setTimeout(exec, lag);
6771
}
6872

6973
#render() {
@@ -152,29 +156,31 @@ export class DeviceViewport {
152156
return [k.replace(/-([a-z])/g, g => g[1].toUpperCase()), v || true];
153157
}));
154158

155-
push(id, config, priority = 1) {
159+
push(id, config, { priority = 1, lag = 0 } = {}) {
156160
if (!id) throw new Error("push() requires a unique ID");
157161
if (this.#stack.some(e => e.id === id)) return;
158162

159163
const peek = this.peek();
160164
if (peek._priority - priority >= 0.2) {
161-
this.#stack.push({ ...config, ...peek, id, _priority: priority });
165+
this.#stack.push({ ...config, ...peek, id, _priority: priority, _lag: lag });
162166
} else {
163-
this.#stack.push({ ...peek, ...config, id, _priority: priority });
167+
this.#stack.push({ ...peek, ...config, id, _priority: priority, _lag: lag });
164168
}
165169

166-
this.#scheduleRender();
170+
this.#scheduleRender(lag);
167171
}
168172

169173
pop(...ids) {
170174
if (!ids.length) throw new Error("pop() requires a target ID");
175+
let lag = 0;
171176
ids.forEach((id) => {
172177
const idx = this.#stack.findIndex(e => e.id === id);
173178
if (idx > 0) { // Never pop the initial state at index 0
174-
this.#stack.splice(idx, 1);
179+
const [entry] = this.#stack.splice(idx, 1);
180+
lag = Math.max(lag, entry._lag);
175181
}
176182
});
177-
this.#scheduleRender();
183+
this.#scheduleRender(lag);
178184
}
179185

180186
peek() { return this.#stack[this.#stack.length - 1]; }

src/webflo-runtime/webflo-client/WebfloClient.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class WebfloClient extends AppRuntime {
4141
super(bootstrap);
4242
this.#host = host;
4343
Object.defineProperty(this.host, 'webfloRuntime', { get: () => this });
44-
this.#location = new URLPlus(this.host.location);
44+
this.#location = new URLPlus(decodeURI(this.host.location.href), undefined, { compatMode: false });
4545
this.#navigator = {
4646
requesting: null,
4747
redirecting: null,
@@ -51,7 +51,7 @@ export class WebfloClient extends AppRuntime {
5151
};
5252
this.#transition = {
5353
from: new URLPlus(window.origin),
54-
to: new URLPlus(this.host.location),
54+
to: new URLPlus(decodeURI(this.host.location.href)),
5555
rel: 'unrelated',
5656
phase: 0
5757
};
@@ -437,7 +437,7 @@ export class WebfloClient extends AppRuntime {
437437
// Transition UI
438438
await this.transitionUI(async () => {
439439
// Set post-request states
440-
Observer.set(this.location, 'href', scopeObj.finalUrl);
440+
Observer.set(this.location, 'href', decodeURI(scopeObj.finalUrl));
441441
scopeObj.resetStates();
442442

443443
// Error?

src/webflo-runtime/webflo-client/webflo-elements.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ export class ModalElement extends BaseElement {
529529
setTimeout(() => {
530530
if (minmaxEvents) observer.observe(this.#spacingElement);
531531
if (swipeDismiss) observer.observe(this.#sentinelElement);
532-
}, 200);
532+
}, 300);
533533

534534
this.#unbindMinmaxWorker = () => observer.disconnect();
535535
}
@@ -703,11 +703,13 @@ export class ModalElement extends BaseElement {
703703
--backdrop-filter: var(--modal-backdrop-filter, blur(3px));
704704
705705
--radius-length: var(--modal-radius, 1rem);
706+
--entry-exit-transition-duration: var(--modal-entry-exit-transition-duration, 0.3s);
706707
707708
--background: var(--modal-background, rgba(80, 80, 80, 1));
708709
709710
--background-accent: var(--modal-background-accent, var(--background));
710711
--color-accent: var(--modal-color-accent, var(--color-default));
712+
--radius-accent: var(--modal-radius-accent, 0px);
711713
712714
--color-default: var(--modal-color-default, whitesmoke);
713715
--color-info: var(--modal-color-info, whitesmoke);
@@ -789,10 +791,10 @@ export class ModalElement extends BaseElement {
789791
790792
:host {
791793
transition:
792-
opacity 0.2s,
793-
transform 0.2s,
794-
overlay 0.2s allow-discrete,
795-
display 0.2s allow-discrete;
794+
opacity var(--entry-exit-transition-duration),
795+
transform var(--entry-exit-transition-duration),
796+
overlay var(--entry-exit-transition-duration) allow-discrete,
797+
display var(--entry-exit-transition-duration) allow-discrete;
796798
transition-timing-function: ease-out;
797799
798800
transform: var(--exit-transform);
@@ -816,10 +818,10 @@ export class ModalElement extends BaseElement {
816818
817819
:host::backdrop {
818820
transition:
819-
display 0.2s allow-discrete,
820-
overlay 0.2s allow-discrete,
821-
backdrop-filter 0.2s,
822-
background 0.2s;
821+
display var(--entry-exit-transition-duration) allow-discrete,
822+
overlay var(--entry-exit-transition-duration) allow-discrete,
823+
backdrop-filter var(--entry-exit-transition-duration),
824+
background var(--entry-exit-transition-duration);
823825
}
824826
825827
:host(:popover-open)::backdrop {

src/webflo-runtime/webflo-routing/HttpEvent111.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class HttpEvent111 {
3030
node._context.parentEvent = this;
3131
});
3232

33-
this.#url = new URLPlus(this.#init.request.url, undefined, { immutable: true });
33+
this.#url = new URLPlus(this.#init.request.url, undefined, { immutable: true, compatMode: false });
3434

3535
this._parentEvent?.signal.addEventListener('abort', () => this.#abortController.abort(), { once: true });
3636
this.#init.request.signal?.addEventListener('abort', () => this.#abortController.abort(), { once: true });

0 commit comments

Comments
 (0)