Skip to content

↕️ A component to help transition to height auto

License

Notifications You must be signed in to change notification settings

tallarium/ember-expander

This branch is 35 commits behind zestia/ember-expander:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c36b015 · Apr 21, 2023
Jan 26, 2023
Mar 1, 2023
Feb 21, 2023
Apr 21, 2023
Feb 13, 2020
Jan 26, 2023
Dec 19, 2021
May 17, 2022
May 17, 2022
Jan 26, 2023
Dec 19, 2021
Apr 1, 2021
Dec 18, 2020
Oct 29, 2019
May 17, 2022
Jan 26, 2023
Oct 29, 2019
Feb 21, 2023
May 17, 2022
Feb 13, 2020
Feb 21, 2023
Jan 26, 2023
Dec 18, 2020
Feb 21, 2023
Feb 21, 2023
Dec 18, 2020

Repository files navigation

@zestia/ember-expander

Latest npm release Ember Observer

Transitioning an element from a zero height to it's actual height is not possible to do with pure CSS, unless you know the height in advance.

This component automatically sets max-height, so that you can style transitions to that height.

Installation

ember install @zestia/ember-expander

Demo

https://zestia.github.io/ember-expander

Features

Notes

  • This addon intentionally does not come with any styles.
  • It is configured with ember-test-waiters so awaiting in your test suite will just work.

Example

<Expander as |expander|>
  <expander.Button {{on 'click' expander.toggle}}>
    Toggle
  </expander.Button>
  <expander.Content>
    Hello World
  </expander.Content>
</Expander>

Expander

Arguments

@expanded

Optional. Expanders are rendered as collapsed by default. Use this argument to manually control their expanded/collapsed state.

@onReady

Optional. This action exposes an API for full control over an Expander.

@onExpanded

Optional. This action fires after the content has rendered and the transition to reveal that content has finished.

@onCollapse

Optional. This action fires after the transition to hide the content has finished, and the content has been removed from the DOM.

API

Content

The area to render the content

contentElement

The DOM element, when expanded

toggle

Toggles the expanded/collapsed state

expand

Expands to reveal the content

collapse

Collapses the content, and un-renders it

isExpanded

Whether or not the content is showing

isTransitioning

Whether or not a transition is in progress to reveal or hide the content.

Further explanation

Expanding

When expanding, the component will automatically set the max-height. This allows you to use a CSS transition to expand to full height, and reveal the content. max-height goes from:

  • none (collapsed)
  • zero (required to start the transition)
  • scroll height (the destination of the transition)
  • none (expanded)

The max-height is removed after expansion, this is so that if the contents of your element subsequently changes, the DOM element can still grow or shrink to fit that new content - without cutting it off, or causing an accidental transition.

Collapsing

When collapsing, the component will automatically set the max-height. This allows you to use a CSS transition to collapse to zero, hiding the content. max-height goes from:

  • none (expanded)
  • scroll height (required to start the transition)
  • zero (the destination of the transition)

About

↕️ A component to help transition to height auto

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 81.2%
  • Handlebars 9.7%
  • HTML 6.7%
  • SCSS 2.4%