BrentonCozby / dom-slider

Plain JavaScript version of jQuery's slideToggle(), slideDown(), & slideUp(), but does not use display: none.
MIT License
61 stars 7 forks source link

Doesn't work if element is hidden by default via CSS #2

Closed bridgeport closed 5 years ago

bridgeport commented 6 years ago

I was looking for something like this (thanks for writing it), but it doesn't look like it works if the element to be toggled is hidden by default using display: none

For instance, if this were to be used for a FAQ toggler, the answers wouldn't be revealed when the questions were clicked.

BrentonCozby commented 6 years ago

Try now. Just pushed some updates. No change to how you use it. Some caveats I must mention though:

When using slideToggle on elements that start with display: none, there will be a slight jump in the slide if you have padding or margin because I was only able to slide the height. However, this will not be an issue on the second, third, and all the following slides on that element.

Another caveat, when using slideToggle on elements that start with display: none, their display value will be set to block.

This is the best I could do at the moment. Hoping some betters ideas will come to mind later. Thanks for raising the issue. 😄

bridgeport commented 6 years ago

@BrentonCozby Your latest release works. Thanks.

At first I didn't notice a change, but realized the cdn.rawgit.com had an older, non-cache-busted version. Have you thought about submitting this to something like CDNJS?

BTW, I noticed https://github.com/BrentonCozby/dom-fader is affected with the 'hidden by default' issue as well. Should I open up this issue there?

Thanks again.