Animate from display none

Animate from display none

Kevin Powell

2 года назад

152,533 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@solongdygaming4729
@solongdygaming4729 - 18.11.2023 15:50

What modal[open] mean?

Ответить
@bzchii7474
@bzchii7474 - 03.11.2023 22:30

God bless framer motion

Ответить
@lukedorny
@lukedorny - 30.10.2023 21:43

Well,shoot. I was hoping there was an CSS-only solution for this. Hmmm.

Ответить
@squirecd
@squirecd - 18.10.2023 11:40

Backdrop animation still broken in Firefox a year later. What a disaster.

Ответить
@PeriklesPeriklesoglu
@PeriklesPeriklesoglu - 12.10.2023 17:54

thank you

Ответить
@archangel_one
@archangel_one - 09.09.2023 22:30

WAIT! I can make this even MORE ridiculously complicated for no apparent reason! Second thought....hmm....

Ответить
@oussamasethoum1665
@oussamasethoum1665 - 25.07.2023 20:15

Thank you

Ответить
@darkflar3
@darkflar3 - 30.06.2023 02:29

You make me fall in love with css❤

Ответить
@lxc3909
@lxc3909 - 14.06.2023 00:01

I keep trying to get away from jQuery and/or jQueryUI completely; however, this video is a fantastic 22-minute sales pitch for jQueryUI, which has jQuery's toggleClass method that takes animation parameters--and it works fine with display:none. Without jQueryUI, this video shows the extremely long cascade of a problem with a solution, with a problem with a solution, with a problem...

Ответить
@r_a__u____l
@r_a__u____l - 19.05.2023 22:43

Instead of javascript and "closing" attribute, a position: fixed; with top: -10000; left: -10000; would work as well, I guess?!? (I have to test it)

Ответить
@AlThePal78
@AlThePal78 - 25.02.2023 17:05

rather not use the :: backdrop if it is not working lol

Ответить
@gergopeto3554
@gergopeto3554 - 15.02.2023 00:22

Kevin, your videos are amazing and help me a lot!

Ответить
@genaroibc
@genaroibc - 06.02.2023 00:19

In this moment we all are hating the CSS design team who made the display property unanimable.

Ответить
@JulianColeman03
@JulianColeman03 - 13.01.2023 19:10

Do the animations still play when you hit either the Esc or Enter keys?

Ответить
@camar078
@camar078 - 25.12.2022 13:58

All in all it's a pain in the a... I solved the problem with a setTimeout function which sets the display attribute to none after my fadeout animation finished which needs less workarounds for it to work.

Ответить
@heckyes
@heckyes - 22.12.2022 02:06

Just seems ridiculous how some of the most obvious requirements of CSS require so much hack-around.

Ответить
@schworak
@schworak - 01.12.2022 20:45

OH MAN! How didn't I know that {once:true} trick before now??? HOW??? Thanks!

Ответить
@radenmulyadi2589
@radenmulyadi2589 - 11.11.2022 16:55

somebody need to hire Kevin to make xss payload

Ответить
@dand8282
@dand8282 - 15.10.2022 08:29

Does pressing [Esc] in the modal still close and animate?

Ответить
@joeldcanfield4282
@joeldcanfield4282 - 12.10.2022 17:48

after a couple years of health challenges making my brain too foggy for words, I'm binging all the KP vids I've missed. I also, this month, for the first time ever, heard your gretting correctly. (After finding zero references to "Canadian slang friend and friends")

Ответить
@danielpalm9091
@danielpalm9091 - 12.10.2022 06:23

Great video as always. I don’t understand when the display:none gets removed

Ответить
@qm3ster
@qm3ster - 08.10.2022 21:27

I would just do
if (!modal.hasAttribute('closing')) return
and install that EventListener on load, without `once` to avoid listener registration churn.

Ответить
@nassim2799
@nassim2799 - 22.09.2022 21:47

I don't think setting the shadow spread to 100vw is a good idea as it won't work as intended on screens that has portrait orientation because in that case the width is always smaller than the height thus on mobile devices the shadow won't be enough to reach to the top and bottom edge of the screen since it's limited to the devices viewport width which is smaller than the height as mentioned at the beginning, great video though.

Ответить
@seanpaulson9098
@seanpaulson9098 - 03.08.2022 09:00

I'm having trouble with this in react. The div animates but the children won't close.

Ответить
@djalexxxgr
@djalexxxgr - 14.07.2022 00:06

Any hack to make css collapse/expand animation on height or width?

Ответить
@goonholiday656
@goonholiday656 - 29.06.2022 00:10

Dialog doesn’t seem to be supported on iOS despite specification saying it does

Ответить
@Xhicko
@Xhicko - 20.06.2022 11:46

I've been searching for this solution for almost 24hours, Never knew display properties were not animatable...Thanks Kevin :)

Ответить
@RobertFlack
@RobertFlack - 20.05.2022 20:00

FYI, instead of using the 'animationend', if you use Promise.all(modal.getAnimations().map(a => a.finished).then(() => { /* dialog close code */ }) then it will only run the dialog close code once all of the animations have finished.

Ответить
@aurorapaisley7453
@aurorapaisley7453 - 20.05.2022 04:57

you know a CSS effect is bonkers when Kevin Powell is forced to use javascript

Ответить
@noureddine2228
@noureddine2228 - 12.05.2022 17:48

i think we can overcome the issue with customising the two animations by using event.animationName to know when to remove the attr & close the modal. we'll also have to remove the once and manage that ourselves

Ответить
@cancer10in
@cancer10in - 12.05.2022 04:40

Thank you for keeping my request and creating this video ❤️❤️❤️

Ответить
@hmm5630
@hmm5630 - 10.05.2022 01:13

youre videos are spot on man! keep up the great work!
wanted to let you know that you inspired me like half a year ago to get back to coding again, i never studied web development before, but after seeing a couple of your videos i was instantly hooked.

with your help i got good with css and html, but i didnt stop there, i learned A LOT more, js for dom manipulation, and after that came serverside nodejs and now i host my own web application thats actually useful to a company.

and now this video, i was just thinking about how can i animate display:flex to display:grid, to make the change smoother. did google implement mindreading algorithm or what?

Ответить
@-0-__-0-
@-0-__-0- - 28.04.2022 15:30

Wow this is what I was looking for damn, thank you!

Ответить
@joyvideos1802
@joyvideos1802 - 26.04.2022 07:35

It's helpful Thanks Kevin

Ответить
@tomcoop9750
@tomcoop9750 - 25.04.2022 18:24

This is awesome! Another option would be to create an open and close class with opacity transitions. Then add or remove the classes with JS and use a setTimeout to “display:none” after the object finishes fading.

Ответить
@zip753
@zip753 - 21.04.2022 22:34

One caveat with the box-shadow workaround is that you probably need max(100vw, 100vh) instead, because if the height is bigger than width then the shadow won't cover the whole screen ;)

Ответить
@germanmartirosyan6230
@germanmartirosyan6230 - 21.04.2022 22:12

Great!

Ответить
@v0xl
@v0xl - 21.04.2022 20:46

There's another solution:
pointer-events none. kinda hacky tho.

Ответить
@morning5tarr
@morning5tarr - 21.04.2022 08:02

I just do setTimeout display none, after opacity 0; I mean if you are already using js then why not.

Ответить
@StripedLime
@StripedLime - 21.04.2022 01:56

What JS book would you suggest to go along with CSS? (And forms)

Ответить
@wolframzell6162
@wolframzell6162 - 19.04.2022 10:00

There is also an event "transitionend", so you can do the same thing with transitions.

Ответить
@MortCodesWeb
@MortCodesWeb - 19.04.2022 09:50

Or just use the visibility property

Ответить
@tasmto
@tasmto - 19.04.2022 09:30

Wow!
Thats once: true was especially eye poppingly gorgeous and elegant!

Ответить
@dkazmer2
@dkazmer2 - 19.04.2022 06:18

The backdrop is still there in the FF solution, right, meaning you can still click it to close the dialog?

Ответить
@jadhajali2804
@jadhajali2804 - 19.04.2022 01:49

hmmm I thought you were struggling with this because you were using css only... but after I saw you using JS, I was like why would you hassle yourself with all this...


Do a check on js for opacity of the element, if (opacity == 0 ) set the element's display to none.

Or is there a problem with that logic? (I haven't tested anything, just at the top of my mind )

Ответить
@dom8429
@dom8429 - 18.04.2022 18:26

I used the same solution for animating the <details> / <summary> from display none. giving it a temporary closing state is a great solution :)

Ответить