Тёмный

Stripe Follow Along Dropdown Navigation -  

Wes Bos
Подписаться 178 тыс.
Просмотров 25 тыс.
50% 1

How to re-create the amazing Stripe dropdown follow-along navigation. Grab all the exercises and starter files over at JavaScript30.com

Наука

Опубликовано:

 

16 окт 2017

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 35   
@Max-zy2ie
@Max-zy2ie 4 года назад
For the css, do not do "transition: all 0.3s...", transition only the transform (transition: transform 0.3s, ...) . Otherwise it will also transition the box-shadow which will degrade performance and make it laggy.
@christostsangaris4785
@christostsangaris4785 4 года назад
I am always impressed of how much you can learn in 21 minutes if the person explaining it rocks!! Great work Wes!
@criptoiners
@criptoiners 2 года назад
I don't know why this channel is sooo unrated, @Wes Bos you are amazing! Thanks a lot for your content!!!!
@SylvainProov
@SylvainProov 4 года назад
- Client: Hey Wes, Thanks for the dropdown ! By the way, i want to add a level 2 and level 3 submenus with the same effect. Thanks.
@scottyzen88
@scottyzen88 5 лет назад
Top class stuff Wes.
@bonzo6989
@bonzo6989 3 года назад
I just came to say BBQ joke is hilarious!!!!! man i was laughing hard when I saw it :D thanks for challanges and good energy bro
@mahesh-waghmare
@mahesh-waghmare 6 лет назад
This is awesome.
@BlueIceAce2015
@BlueIceAce2015 5 лет назад
So good, thank you so much!
@boomer5015
@boomer5015 6 лет назад
This is cool, thanks for showing. Few enhancements come to mind: - Use visibility: hidden and pointer-events: none instead of display: none. This means you don't need the -active class as these properties are toggles, with the opacity taking care of the transition effect.. Also means, you can pre-cache the getBoundingClientRect() coords. - Transform the dropDown Background X and Y instead of changing width/height (saves on layout calcs). Would require calculating but can also be pre-cached. As the dropdown is it's own node, it won't impact the content but it will require decoupling or inverse transforms on the span arrow. - Have a wrapper/container element as a direct child to Nav and parent to the other elements within. This can be position relative, allowing the dropDown background to be positioned absolutely against it. Then, you can translateX based on coords from the relevant 's. This means position of the NAV doesn't impact. There's an assumption that the NAV is full width, if not then you still need the getBoundingClientRect(). * A wrapper element may impact semantics this is simply an alternate option.
@joshhwb
@joshhwb 6 лет назад
Good thinking. Care to show a demo of this?
@boomer5015
@boomer5015 6 лет назад
Been working on it, still got a day or so to go -> Will post the repo when done. I'm using ES6 classes and request animation frame instead of CSS transition. When I create instances of the dropdown menus, I measure the getBoundingClientRect to find the max dropdown area. I then use the width and height of this to assign as width and height to the dropdown background. This way, when you scale up and down it doesn't distort the appearance of the background too much. I'm using aria-expanded attribute instead of classes to manage state. I'm also using a game timer (check out Meth Meth Methods channel) to calculate the transforms and opacity changes (using an easing function) at 120FPS. Then request animation frame kicks in to paint when it can, hopefully this means smoother animation (I guess we'll see). I also detect when you mouse enter/leave the nav bar to kick off/cancel the animation frame as well as add/remove event listeners on the individual triggers. Also, trying to manager layer promotion dynamically with will-change (See Swipeable Cards vid from Google Devs). The stripe site also applies a cool 3D transform when you first hover a trigger so may look to implement that as well. Like any Javascript UI, it snowballs real quick haha!!
@joshhwb
@joshhwb 6 лет назад
Putting in some real work to it! Nice I'm excited to see the finished product :)
@limited06
@limited06 6 лет назад
Any update to this? Intrigued to see whether caching the values will have an effect on responsive (i.e you rotate the device after page loads).
@boomer5015
@boomer5015 6 лет назад
I still have quite a bit to go, sorry have been busy with work and this has sort of snowballed. Here's the repo in it's current state, just 'npm install' then 'npm run dev' to compile via webpack and host on webpack-dev-server: github.com/DannyLingard/nav-follow. Check back regularly for updates, will update the readme as well. There's a lot of spaghetti, debugging and testing code still in there as was having trouble killing the animation frame and removing event listeners from the triggers. I was also having issues managing 'this' as things weren't originally behaving as expected. You'll see I .bind(this) instead of using arrow functions in some places, this is because to removeEventListeners(), you need to provide the exact function signature that you pass to the callback of addEventListener(). Turns out, you can't use anonymous functions in the callback (maybe you can with advanced trickery but even MDN docs were light on examples/guidance). Like any Javascript UI work, there's always a lot of bases to cover if you want it to be robust in production. Although this won't have be completely production ready, I'm hoping to incorporate some aspects like managing requestAnimationFrame useage, layer promotion, as well as adding/removing event listeners when possible. Although this increases complexity, the end result is a component that only uses transforms and opacity changes for movement and is a lot more perform ant. Flip side, it takes x amount of time longer to build so all depends on priorities. Currently, both the translate and scale transforms are wired up for the dropdown background but opacity is still operating via CSS. The triangle at the top of the Dropdown background is currently always visible. I have a ton of refactoring to do as well as some functional programming techniques I want to test out so the code may be changing a lot. In terms of the cache values, these will need to be updated whenever the viewport changes, either via resize or orientation change. This will require additional event listeners which are usually done at app level. I'll see if I can include method hooks to handle dynamic recalc etc. I don't know whether I'll have the time to invest in that but we'll see how it goes.
@nus
@nus 5 лет назад
Holy shit! I was watching this in my bed to confuse my mind and sleep because there’s nothing better than watching someone talks and codes to distract your brain then sleep but this 20 mins of video is going to change a looooot of things in my life first of all why the hell didn’t I found this display thing before! If I know this before I can do a lot of great stuff I know at least 20 animations I couldn’t make it responsive to width and height change because of this, shit man this saved my life! and the second thing is how crazy is that coordinate API this is just fucking perfect, I can do unlimited things with just this two little things, Wes you are the best teacher I have ever had, I want to thank you so much, this 20 mins of video sadly wake me up yet it’s very very valuable to me, I’m super relieved right now thank you ❤️
@madtin
@madtin 6 лет назад
This is sweet.
@riandpratama6018
@riandpratama6018 6 лет назад
so awesome
@cgarafulic
@cgarafulic 3 года назад
Hello Wes, I loved the video. Thank you so much! Is there any repo or page to find the HTML markup and CSS for the starting point?
@JJ-ot3ps
@JJ-ot3ps 2 года назад
nice tutorials! I am wondering if it is possible to do this with headless UI or tailwind?
@Pudong0923
@Pudong0923 5 лет назад
Hey Wes, what's the title/band of the background music you used in this video?
@CherryPoppinz
@CherryPoppinz 5 лет назад
One more idea / comment / question. To prevent multiple li's having the active class, couldnt you just set the setTimeout in handleEnter to 1ms? I find that it works, is there any scenarios that I may not be thinking of where it wouldnt?
@christostsangaris4785
@christostsangaris4785 4 года назад
The first time you hove over an item with dropdown, you see the box coming from the top-left side to the correct coordinates. Is there a way to prevent this from happening?
@heyyy4987
@heyyy4987 6 лет назад
nice
@vladislavmoroshan3749
@vladislavmoroshan3749 6 лет назад
Why we need class "dropdownBackground" at all? We can add background properties to "trigger-enter .dropdown" directly.
@waheedahmed6602
@waheedahmed6602 3 года назад
Hey, great video! im having this issue where if i try to hover over child elements of the li, it kinda triggers the mouseleave event, can you give me a solution for it? Thanks!
@s.a.Tawhid
@s.a.Tawhid 2 года назад
😲 for the arrow function
@paulmoldovan9518
@paulmoldovan9518 4 года назад
This is verry nice. But one thing what you forgot. If there is no dropdown all this will messed up.
@kwhandy
@kwhandy 4 года назад
are you fearless records alumni or ex-vans world tour?
@Wadhwakaran96
@Wadhwakaran96 6 лет назад
Which sublime theme is that?
@nealpatel7696
@nealpatel7696 6 лет назад
Cobalt2! He created the theme haha.
@khiemsola
@khiemsola 6 лет назад
my mind just blew away
@nealpatel7696
@nealpatel7696 6 лет назад
Haha, the guy's really good. He also made one for VS Code.
@akhilanair3634
@akhilanair3634 6 лет назад
This is awesome but not as such as stripe
Далее
❤️My First Subscriber #shorts #thankyou
00:26
Просмотров 4,6 млн
Try not to Laugh Game!
00:38
Просмотров 4,6 млн
Custom fields in Stripe Checkout
11:31
Просмотров 10 тыс.
Ajax Type Ahead with fetch() - #JavaScript30 6/30
17:22
Variable amount pricing in Stripe Checkout
7:32
Просмотров 11 тыс.
Master Python With This ONE Project!
56:54
Просмотров 10 тыс.
JS Checkbox Challenge! #JavaScript30 10/30
11:19
Просмотров 29 тыс.
Игровой Комп с Авито за 4500р
1:00
#engineering #diy #amazing #electronic #fyp
0:59
Просмотров 315 тыс.