Bindings, Actions & Transitions
เชื่อม component เข้ากับ DOM และ motion
หัวข้อที่มีชื่อว่า “เชื่อม component เข้ากับ DOM และ motion”runes ให้ reactive state; โมดูลนี้ครอบคลุม directive ที่เชื่อม state นั้นเข้ากับ DOM element จริงและกับ motion:
- Bindings (
bind:) สร้าง link สองทางระหว่าง state กับ DOM property — input update state และ state update input - Actions (
use:) run โค้ด setup แบบ imperative บน element ตอน mount — escape hatch สำหรับ library ที่ไม่ใช่ Svelte, focus, tooltip และ click-outside - Transitions & animations (
transition:,animate:) animate element แบบ declarative ตอนเข้า ออก และเรียงใหม่
โมดูลนี้ครอบคลุมอะไรบ้าง
หัวข้อที่มีชื่อว่า “โมดูลนี้ครอบคลุมอะไรบ้าง”| บทเรียน | สิ่งที่จะได้เรียน |
|---|---|
| Bindings | bind:value, bind:this, bind:group และ component binding |
| Actions | use: directive และ action lifecycle |
| Transitions & animations | transition:/in:/out: และ animate:flip |
| Forms & inputs | controlled input, validation และการจัดการ submit |
flowchart TB state["reactive state (runes)"] --> bind["bind: link สองทางกับ DOM property"] state --> action["use: setup แบบ imperative บน element"] state --> trans["transition: / animate: motion แบบ declarative"] bind --> dom["the DOM"] action --> dom trans --> dom