How to Use the Resize Observer API

  Рет қаралды 8,342

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

4 жыл бұрын

This video covers the 3rd of the Observer APIs added in HTML5 - the Resize Observer. It gives a practical example of how this Observer is different from CSS Media Queries.
Also discussed briefly is the new Optional Chaining Operator.
Intersection Observer API video: • IntersectionObserver API
Mutation Observer API video: • Capture DOM Changes wi...
code from video: gist.github.com/prof3ssorSt3v...

Пікірлер: 26
@jayreyes828
@jayreyes828 2 жыл бұрын
The concise explanation of optional chaining is this video's cherry on top.
@shvideo1
@shvideo1 4 жыл бұрын
What a great example to show the usefulness of Resize Observer. Great video... very well taught. Thank you for sharing your knowledge.
@dominiktargosz3094
@dominiktargosz3094 3 жыл бұрын
I like your videos because you talk about important but overlooked topics
@adityasethi9794
@adityasethi9794 3 жыл бұрын
You're too good. Speed is perfect and the way you explain is also great. Thanks!
@ricardopassos1180
@ricardopassos1180 3 жыл бұрын
I couldn't agree more.
@nickstaresinic9933
@nickstaresinic9933 3 жыл бұрын
Nice. Clear, simple, & useful. Thanks.
@raba650
@raba650 3 жыл бұрын
Awesome video! I'm using window.resize with React right now and I just had to go back to vanilla JS to touch up on the basics. Thanks.
@tradewinds9832
@tradewinds9832 3 жыл бұрын
Nice one. Thanks for sharing. Clean and easy to understand.
@krishnateja7830
@krishnateja7830 3 жыл бұрын
Great video, mate!
@Finn-jp6pn
@Finn-jp6pn 4 жыл бұрын
Great video! Thanks. Subbed!
@minshuotang4511
@minshuotang4511 3 жыл бұрын
Thanks for the video! How to use the resize observer If I want to observe the width changes of multiple divs that have the same ".container" class?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
You just call the observer method on each element.
@michelange5102
@michelange5102 4 жыл бұрын
Dynamight!!!
@karuheine1152
@karuheine1152 3 жыл бұрын
I don't know why if it is wrong, but with the resize Observer, can I invoke different functions? For example, mobile view have links that has some functionalities in it and it opens differently and when it is now in desktop view, those functionalities should be gone and set new functionalities if I use the resize observer with if statements, right? I tried this so many times now and it results into double execution of functions. It is frustrating. Code Example let width = entries[0].contentRect.width; if (width < 480) { openLinksMobile(); // It opens sideward } else { openLinksDesktop(); // It opens downward } Thank you for the video I have learned a lot with this, but somehow it doesn't work for that kind of example I have shown.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Observers can fire many times. It's not just a one time call to the handleResize function. I would consider using media queries to change what is shown and how things are shown through CSS. OR using the matchMedia( ) method - kzbin.info/www/bejne/bJe3eJ1nib5pqKc - inside an openLinks function to decide what to do.
@4541047
@4541047 4 жыл бұрын
Nice video. When to use resizer observer over addEventListener('resize', ...)?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
The observer let's you target things other than the window for size changes.
@4541047
@4541047 4 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thanks!
@AdrianSkar
@AdrianSkar 2 жыл бұрын
Thank you very much. What's the difference between *Element.parentElement.removeChild(Elem)* and *Element.remove()*?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 2 жыл бұрын
removeChild( child ) remove( ) the first removes a child element the second removes the element that is calling the method.... kzbin.info/www/bejne/rXm5fXyNnst5rtk
@theartist8835
@theartist8835 3 жыл бұрын
Could you please make a video on performance observer, giving some use cases?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Please add that in the comments here - kzbin.info/www/bejne/gnTIq5SuZ9qBacU
@theartist8835
@theartist8835 3 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Done! thank you!
What's the difference between remove and removeChild
9:40
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 4,7 М.
How To Create A Video Chat App With WebRTC
28:53
Web Dev Simplified
Рет қаралды 900 М.
Каха и суп
00:39
К-Media
Рет қаралды 4 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4,3 МЛН
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
Things Every Developer Should Know About package.json
15:41
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 48 М.
Enums considered harmful
9:23
Matt Pocock
Рет қаралды 197 М.
The secret to mastering CSS layouts
17:11
Kevin Powell
Рет қаралды 269 М.
Responsive picture college with media query
24:29
Asifa Jahan Safa
Рет қаралды 14
Resize Observer - HTTP203
5:19
Chrome for Developers
Рет қаралды 12 М.
The Unreasonable Effectiveness Of Plain Text
14:37
No Boilerplate
Рет қаралды 591 М.
Using FormData Objects Effectively
13:14
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 36 М.
3 Levels of Mind Maps Every Student MUST Master
21:31
Justin Sung
Рет қаралды 51 М.