Tan Li Hau 🤔 Profile picture
👨🏻‍💻 🇲🇾 🥰 Sharing tips on Svelte, React, CSS 📝 Occasionally writes about one layer of abstraction below at https://t.co/dMg56WXWzG 💻 @sveltejs maintainer

Apr 5, 2021, 9 tweets

How much do you know about the 7 event modifiers in @sveltejs?

Let's take a look what you need to write if you don't have them 👇

1️⃣ preventDefault

this is equivalent of calling event.preventDefault() on the start of the event handler

2️⃣ stopPropagation

this is equivalent of calling event.stopPropagation() on the start of the event handler

3️⃣ passive

this is equivalent of calling addEventListener() with { passive: true }

4️⃣ nonpassive

this is equivalent of calling addEventListener() with { passive: false }

5️⃣ capture

this is equivalent of calling addEventListener() with { capture: true }

6️⃣ once

this is equivalent of calling addEventListener() with { once: true }

7️⃣ self

this is equivalent of checking if the event.target === current element

You can check on how to use them in detail in my YouTube video

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling