Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/showable
Mixin for views to make them show and hide
https://github.com/segment-boneyard/showable
Last synced: about 5 hours ago
JSON representation
Mixin for views to make them show and hide
- Host: GitHub
- URL: https://github.com/segment-boneyard/showable
- Owner: segment-boneyard
- Created: 2014-02-10T19:49:02.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-06T20:07:32.000Z (almost 10 years ago)
- Last Synced: 2024-04-09T16:31:15.223Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 206 KB
- Stars: 9
- Watchers: 45
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# showable
Mixin for views to add `show` and `hide` methods. Used by things like dialogs and overlays
that need to show and hide, but need to account for transitions too.Toggles a `.hide` class on the view.
## API
```js
var showable = require('showable');showable(MyView.prototype);
```
Then you might listen for events to add and remove it from the DOM:
```js
function MyView() {
this.on('showing', function(){
document.body.appendChild(obj.el);
});
this.on('hide', function(){
document.body.removeChild(obj.el);
});
}
```## Methods
### #show(fn)
Show the view. Emits `showing` immediately, and `show` when the view is fully visible (after transitions). Removes `.hide` class.
Optional callback is fired when it has finished showing.
### #hide(fn)
Hide the view. Emits `hiding` immediately, and `hide` when the view is fully hidden (after transitions). Adds `.hide` class.
Optional callback is fired when it has finished hiding.