blockless
Rich Harris 2 years ago
parent c2df07f58a
commit 044c1a1975

@ -88,6 +88,8 @@ const all_registerd_events = new Set();
/** @type {Set<(events: Array<string>) => void>} */
const root_event_handles = new Set();
export let run_transitions = true;
/**
* @param {string} html
* @param {boolean} return_fragment
@ -2547,6 +2549,8 @@ function _mount(Component, options) {
const container = options.target;
const block = create_root_block(options.intro || false);
run_transitions = options.intro ?? false;
/** @type {Exports} */
// @ts-expect-error will be defined because the render effect runs synchronously
let component = undefined;
@ -2579,6 +2583,8 @@ function _mount(Component, options) {
const bound_event_listener = handle_event_propagation.bind(null, container);
const bound_document_event_listener = handle_event_propagation.bind(null, document);
run_transitions = true;
/** @param {Array<string>} events */
const event_handle = (events) => {
for (let i = 0; i < events.length; i++) {

@ -18,6 +18,7 @@ import {
managed_pre_effect,
user_effect
} from './reactivity/computations.js';
import { run_transitions } from './render.js';
import {
current_block,
current_effect,
@ -530,7 +531,8 @@ export function bind_transition(element, get_fn, get_params, direction, global)
current_options ??= get_fn()(element, get_params?.(), { direction });
if (!current_options) {
if (!current_options?.duration) {
current_options = null;
callback?.();
return;
}
@ -563,6 +565,7 @@ export function bind_transition(element, get_fn, get_params, direction, global)
.catch(noop);
} else {
// TODO timer
current_options = null;
}
}
};
@ -571,9 +574,11 @@ export function bind_transition(element, get_fn, get_params, direction, global)
if (direction === 'in' || direction === 'both') {
(effect.in ??= []).push(transition);
user_effect(() => {
transition.to(1);
});
if (run_transitions) {
user_effect(() => {
untrack(() => transition.to(1));
});
}
}
if (direction === 'out' || direction === 'both') {

Loading…
Cancel
Save