No video

Dynamic Scroll States with Intersection Observer + Vue

  Рет қаралды 30,076

LearnVue

LearnVue

Күн бұрын

Learn how websites make dynamic table of contents!
✅ FREE VUE 3 CHEATSHEET WITH ESSENTIAL CODE SNIPPETS
learnvue.co/vu...
follow me on twitter:
/ mattmaribojoc
🚨 Like quick Vue lessons like these? Check out 800+ lessons over on Vue School - go.learnvue.co...
Music by Lukrembo

Пікірлер: 42
@somascope1834
@somascope1834 2 жыл бұрын
I observed your video, sir. And it intersected with me very well. Job well done!
@LearnVue
@LearnVue 2 жыл бұрын
haha thank you :)
@thabo5799
@thabo5799 2 жыл бұрын
Dude, you content so good! Keep it up! I’ve showed my team at work your channel and even the seniors love you haha
@LearnVue
@LearnVue 2 жыл бұрын
legend!! thanks for the kind words
@bobdpa
@bobdpa 2 жыл бұрын
These videos are great. I watch for them every week. On your website, you have a green bar that indicates how far you have scrolled down the page. Can you do a video on that? Thanks!
@LearnVue
@LearnVue 2 жыл бұрын
great idea - i had a ton of fun implementing that feature so i'd be happy to add that to the backlog :)
@bobdpa
@bobdpa 2 жыл бұрын
@@LearnVue beautiful!
@wduandy
@wduandy 2 жыл бұрын
Amazing! A great use case for this is on a chat to send feedback to the api that the user had read a message.
@LearnVue
@LearnVue 2 жыл бұрын
Ooh yeah definitely that's a great one.
@yte50
@yte50 2 жыл бұрын
You have my respect. I recently was looking for a way, not until now, how to change my navbar background color when getting to a particular section of a page, and reverting it back when it crosses that section or goes back up. This is beautiful.
@LearnVue
@LearnVue 2 жыл бұрын
appreciate it! glad i was able to help
@caiovinicius7871
@caiovinicius7871 2 жыл бұрын
This scroll style is awesome! Great Video, thanks!!
@abdulrakib9906
@abdulrakib9906 2 жыл бұрын
Need more videos like this. Thank you
@jampy42
@jampy42 2 жыл бұрын
I've seen sometimes people use onDestroy to disconnect the observer, is it necesary?
@aaaa9r
@aaaa9r Жыл бұрын
I think it is. Isn't it called onUnmount?
@laceymain8660
@laceymain8660 Жыл бұрын
i think this is good for my chat application.. I'm thinking about how can i implement a seen messages feature, maybe i can use this. Thanks master 🙏
@damianperez7736
@damianperez7736 2 жыл бұрын
Can you make a video about vue 3 + astro ?, that seems to be even better than just a plain vue 3 spa + vite
@shimonpertz
@shimonpertz Жыл бұрын
Love your videos. Keep it up man
@Jorgeee
@Jorgeee Жыл бұрын
The logic is flawed here. As you can see, the first and second section is never updated, because they are always in the viewport. What you need to do is only change the id when the header comes into contact with another element at the top of the page (an invisible div or something). That way, the current section will only change when the old section is mostly out of view. EDIT: Turns out you cant have the size of the invisible div set to anything you want since you want the target element's root to be a parent. So, you should use the rootMargin option and add a negative margin that will effectively shrink the intersection area. Say -90% bottom margin, which will leave a 10% area of the vh at the top. (set the height of the root div to 100vh)
@user-bx6ny3bb8p
@user-bx6ny3bb8p 8 ай бұрын
how to adjust adjust the intersection observer position and threshold?
@scriptedpixelsltd
@scriptedpixelsltd 2 жыл бұрын
I’m sure it’s not recommended, in Vue, to query to the document directly with query selector?
@nrishinghanandaroy
@nrishinghanandaroy 2 жыл бұрын
Love your videos🎥
@seve-fn1mo
@seve-fn1mo Жыл бұрын
why does using document.querySelectorAll preferred over using ref? Is this only matter of preference?
@adeleke5140
@adeleke5140 Жыл бұрын
In the view docs, not only does the active border gets changed, there's also the hash which is updated. How does one accomplish that? There's also a feature whereby once you scroll out of the container containing the id section, the hash disappears. It's a very interesting feature that I'm trying to replicate.
@LearnVue
@LearnVue Жыл бұрын
this is a built-in vitepress feature (which uses scroll events instead of intersection observers) you can recreate this with intersection observers with Vue Router's replace method to add the hash onto the current route
@andreasblondeau1682
@andreasblondeau1682 2 жыл бұрын
Super helpful, thanks 🙏👍
@jamesryan3007
@jamesryan3007 Жыл бұрын
Is this accessible for users that use the screen reader?
@GajderStudio
@GajderStudio Жыл бұрын
What if the paragraph is much longer let's say longer than the client view height. Then you approach doesn't really work because when you scroll to the section below and then start scrolling up through the very long paragraph (meaning the header is not visible) your TOC still highlights the link to section below even though user came back to read previous very long paragraph. How would we go about this? I have this problem in my app and I cannot get it to work like it works on MDN, tailwind docs or any good documentation. Any tips??
@Jorgeee
@Jorgeee Жыл бұрын
Have you found a solution for this?
@mamdouhzaq
@mamdouhzaq 2 жыл бұрын
Love your videos
@LearnVue
@LearnVue 2 жыл бұрын
love your comment
@RaymondAtivie
@RaymondAtivie 2 жыл бұрын
This is awesome Thank you for this 👍
@LearnVue
@LearnVue 2 жыл бұрын
glad you like it :)
@shahzodcodes
@shahzodcodes 2 жыл бұрын
@@LearnVue hi, can you do another video about rendering items when instersected in order to minimize render elements to dom when first load web app
@ramina2121
@ramina2121 2 жыл бұрын
Great video
@pauliversoncortez1544
@pauliversoncortez1544 Жыл бұрын
hi great video, can you implement this using vue components? hope you recognize my comment.
@KuroManX
@KuroManX 11 ай бұрын
In your template you can use ref inside of your component like , and in your script setup declare const myComponent = ref(null) (for typescript you can use ref(null), then you do observer.observe(myComponent.value)) or check the VUEUSE useInteresectionObserver, the same principal
@RahulSingh-be2mg
@RahulSingh-be2mg 2 жыл бұрын
Amazing!
@revolutionoftheresolution5867
@revolutionoftheresolution5867 2 жыл бұрын
it is not working after changing link and come back to the page again how can we fix it. any idea
@LearnVue
@LearnVue 2 жыл бұрын
i can't be 100% sure, but my thought is that the component is not being mounted on the second load. try playing around with `key` or different lifecycle hooks.
@revolutionoftheresolution5867
@revolutionoftheresolution5867 2 жыл бұрын
​@@LearnVueactually I am using Nuxt 3 so, I found out that using the DOM directly is not a good idea, instead using template ref. it is the way of Vue.
Use Vue Teleport to Make Modals and Popups
4:55
LearnVue
Рет қаралды 31 М.
Простые решения для сложных задач с Intersection Observer API
29:23
Михаил Непомнящий
Рет қаралды 30 М.
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 103 МЛН
Cute kitty gadgets 💛
00:24
TheSoul Music Family
Рет қаралды 17 МЛН
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 87 МЛН
This API is a Life Saver (ft. Intersection Observer)
7:03
노마드 코더 Nomad Coders
Рет қаралды 24 М.
You're Probably Using Nuxt Wrong
5:16
LearnVue
Рет қаралды 21 М.
A very simplified guide on the Intersection Observer API, with examples
21:47
Infinite Scrolling With Vue & VueUse
8:33
John Komarnicki
Рет қаралды 15 М.
The Secret Science of Perfect Spacing
9:40
Chainlift
Рет қаралды 408 М.
Vue Functional Components Simplified
3:09
LearnVue
Рет қаралды 27 М.
The Easiest Way to Build Websites
10:56
Sajid
Рет қаралды 447 М.
Vue Slots Simplified
7:25
LearnVue
Рет қаралды 55 М.
Lazy-Loaded Images - Code This, Not That
4:47
Fireship
Рет қаралды 89 М.