Implement transition for collapsible #575
vegegoku
started this conversation in
Implementations
Replies: 2 comments 2 replies
-
Looking into this and it is still seems to be non-ideal |
Beta Was this translation helpful? Give feedback.
0 replies
-
What about looking into the source code of some popular material design libraries to understand how it's solved there? For example, https://materializecss.com/collapsible.html is implemented in the next way: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current implementation of collapsible in domino-ui uses the
display
css property to show/hide the elements.We can define a Collapsible for an element using the syntaxt
Collapsible.create(someElement)
, and all domino-ui components that extends from BaseDominoElement come already initialized with a collapsible.But since we are using the display property we dont apply transition on hide/show of the element.
and recently on domino gitter channel @bykka suggested that using height and a transition is better for implementing the collapse behavior for Accordions... Which is actually right as it provide a better look and feel. also he shared a quick sample of how this could be implemented https://codepen.io/mbxtr/pen/pCfcy
According to this I went a head ans started to experiment around this feature. and here what I did so far
In the collapsible class I found that the bahvior to show/hide the element is actually isolated from the rest of the logic in the collapsible class, which means we can refactor that bahvior into an external class and inject it into the collapsible class.
So I added a new Interface
CollapseStrategy
and created a a default implementation calledDisplayCollapseStrategy
which uses the current logic in the collapsible , then refactored the collapsible to use this instead of directly implementing the behavior.This means we can also implement as many strategies as we wont and even those who want to build thereown custome ones will be able to do so. but then I also went a head to test this and implement a height with transition startegy ...in this startegy the element will start to shrink in height until it has 0 height. and I noticed that despite how it looks easy and simple it turns out to be more complex than I initially thougt and here are my conclusions :
max-height
instead of height in this case we initially start with a very big max-height despite the actual height of the element and we change the element max-height instead of height, but as this solve the issues with attached state and collapsed initial state it comes with its own issue, as this affect the transition based on the actual height of the element, so with an element with a height very close to the max-height the transition will be smooth while an element with a height much smaller than the assigned max-height will flicker.I am starting this discussion to share ideas/solution/thoughts on this. any contribution is heighly appreciated
Beta Was this translation helpful? Give feedback.
All reactions