3.0.2 • Published 4 months ago

@saekitominaga/customelements-details-animation v3.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
4 months ago

Animating the <details> element

npm version test status

Demo

Examples

<details is="x-details-animation"
  open=""
  data-duration="1000"
  data-easing="linear"
>
  <summary>Caption Text</summary>
  <p>Contents text</p>
</details>

Attributes

* The data-summary-toggle attribute is obsolete in version 3.0.0 .

Sample CSS

In order to achieve animation, the timing of setting the open attribute of the <details> element is delayed. Therefore, the viewlet icon of the <summary> element should be determined by the data-pre-open attribute.

details[data-pre-open] > summary {
  list-style: none;
}

details[data-pre-open] > summary::-webkit-details-marker {
  display: none;
} /* Safari(16) doesn't support `list-style`, so you need to use the `::-webkit-details-marker` pseudo-element <https://caniuse.com/mdn-html_elements_summary_display_list_item> */

details[data-pre-open] > summary::before {
  margin-inline-end: 0.5em;
  display: inline-block;
  content: '▼';
}

details[data-pre-open='false'] > summary::before {
  transform: rotate(-90deg);
}

* Don't forget to add details[data-pre-open] to all selectors. This will avoid styling in environments where JavaScript is disabled or where Customized built-in elements are not supported (e.g. Safari 16).

3.0.2

4 months ago

3.0.1

4 months ago

3.0.0

1 year ago

2.3.0

2 years ago

2.2.1

2 years ago

2.3.1

2 years ago

2.2.2

2 years ago

2.2.0

2 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago