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

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

Loading…
Cancel
Save