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 πŸ‘‡ Image
1️⃣ preventDefault

this is equivalent of calling event.preventDefault() on the start of the event handler Image
2️⃣ stopPropagation

this is equivalent of calling event.stopPropagation() on the start of the event handler Image
3️⃣ passive

this is equivalent of calling addEventListener() with { passive: true } Image
4️⃣ nonpassive

this is equivalent of calling addEventListener() with { passive: false } Image
5️⃣ capture

this is equivalent of calling addEventListener() with { capture: true } Image
6️⃣ once

this is equivalent of calling addEventListener() with { once: true } Image
7️⃣ self

this is equivalent of checking if the event.target === current element Image
You can check on how to use them in detail in my YouTube video

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Tan Li Hau πŸ€”

Tan Li Hau πŸ€” Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @lihautan

6 Jul
If you have a promise waiting for your data, {#await} block makes it easy to express your content in the loading πŸ•‘, resolved βœ… and rejected ❌ state

So, let's talk about the {#await} block in @sveltejs

πŸ‘‡πŸ§΅[THREAD]
Here's the general structure for the {#await} block

πŸ•‘ {#await}
βœ… {:then}
❌ {:catch}
πŸ‘‹ {/await}

[1/4] <script>   let promise; </s...
All the states are optional, so you could have

😜 no loading state
πŸ˜† no resolved state
πŸ˜… no rejected state

[2/4] <script>   let promise; </s...<script>   let promise; </s...<script>   let promise; </s...
Read 8 tweets
5 Jul
We've seen how we can use {#each} to repeat content in @sveltejs ,

let's talk about the keyed each block, and what does it mean to have a key for each block



πŸ‘‡πŸ§΅[THREAD]
πŸ“ΉIf you prefer learning through video, the following thread is a summary from my @YouTube video

πŸ’‘ You can always subscribe to my channel to get notified for the next awesome content!

πŸ‘‰πŸ‘‰ youtube.com/lihautan?sub_c…
Read 14 tweets
1 Jul
HTML doesn't have a way of expressing logic, like conditionals and loops. @sveltejs does.

Let's take a look at the 1st logic block in @sveltejs, πŸ‘‰ {#if} πŸ‘ˆ

πŸ‘‡πŸ§΅ [THREAD]
If you prefer watching video, the following thread is a summary from my @YouTube video
πŸ’‘{#if} is our 1st logic logic block in @sveltejs
πŸ’‘it allow us to conditional render content
πŸ’‘if comes with else, else if, just like you would expect in JavaScript <script>   let value = 42; </script>  {#if value === 42}   <
Read 8 tweets
29 Jun
How do you pass dynamic data when you forward slots in @sveltejs?
Let's recap, here is how you forward slots
and here is how you pass dynamic data into slots

Read 11 tweets
15 Aug 20
Another week on #CSSpodcast, this weeks topic is CSS Functions 😍

🧡
CSS Functions provides runtime contextual expressions that return dynamic real-time value per the state of the browser per user in that moment
- global space, no need import
- can be nested, calc(var(--var))
- typed, eg: `rotate(45px)` will not work
- keep the function live, recompute on value changes and updates
- many of them are pure functions, however, counter-example: `counter()`
Read 20 tweets
12 Jul 20
In the latest episode #CSSpodcast, @Una and @argyleink shared a ton of pseudo-classes

(I managed to note down 3️⃣9️⃣ of them 😱)

🧡 Here is a thread of what were shared in the podcast πŸ‘‡πŸ‘‡πŸ‘‡
Pseudo-classes are selectors, lets you apply style to element based on info outside of the doc tree:

🌎 meta information, eg: language, history of navigator
β˜‘οΈ state of the element, eg: checked, active, disabled

✨Pseudo-classes are great for implementing micro-interactivity
πŸ”€ Case-insensitive
⏹ No whitespace in between
Read 24 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(