Skip to main content

转换函数可以接受参数。 将 fade 转场替换为 fly...

Transition functions can accept parameters. Replace the fade transition with fly...

<script>
	import { fly } from 'svelte/transition';
	let visible = true;
</script>

...并将其与一些选项一起应用到 <p>

...and apply it to the <p> along with some options:

<p transition:fly={{ y: 200, duration: 2000 }}>Flies in and out</p>

请注意,转换是可逆的 — 如果在转换过程中切换复选框,它将从当前点开始转换,而不是开始或结束。

Note that the transition is reversible — if you toggle the checkbox while the transition is ongoing, it transitions from the current point, rather than the beginning or the end.