https://github.com/afeiship/visible-element
Visible element with animation.
https://github.com/afeiship/visible-element
backdrop close element hide overlay react show ui visible vue
Last synced: 30 days ago
JSON representation
Visible element with animation.
- Host: GitHub
- URL: https://github.com/afeiship/visible-element
- Owner: afeiship
- License: mit
- Created: 2018-03-06T05:18:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-28T10:27:09.000Z (about 2 years ago)
- Last Synced: 2025-02-07T10:45:30.705Z (over 1 year ago)
- Topics: backdrop, close, element, hide, overlay, react, show, ui, visible, vue
- Language: TypeScript
- Homepage:
- Size: 84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# visible-element
> Visible element with animation.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```shell
npm install @jswork/visible-element
```
## usage
```html
Toggle
```
```css
[hidden] {
display: none;
}
#my-element {
animation: show 0.3s ease-in-out;
}
#my-element[data-visible="true"] {
animation: close 0.3s ease-in-out;
}
@keyframes show {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes close {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
```
```javascript
import VisibleElement from 'visible-element';
const element = document.getElementById('my-element');
const button = document.getElementById('my-button');
const visible = new VisibleElement(element, {
onShow: () => { console.log('show'); },
onShowed: () => { console.log('showed'); },
onClose: () => { console.log('close'); },
onClosed: () => { console.log('closed'); },
onChange: (status) => { console.log(status); },
});
button.addEventListener('click', () => {
visible.toggle();
});
```
## license
Code released under [the MIT license](https://github.com/afeiship/visible-element/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/visible-element
[version-url]: https://npmjs.org/package/@jswork/visible-element
[license-image]: https://img.shields.io/npm/l/@jswork/visible-element
[license-url]: https://github.com/afeiship/visible-element/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/visible-element
[size-url]: https://github.com/afeiship/visible-element/blob/master/dist/index.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/visible-element
[download-url]: https://www.npmjs.com/package/@jswork/visible-element