https://github.com/bredele/domstack
Stack your dom nodes into a fragment
https://github.com/bredele/domstack
Last synced: about 1 year ago
JSON representation
Stack your dom nodes into a fragment
- Host: GitHub
- URL: https://github.com/bredele/domstack
- Owner: bredele
- Created: 2013-10-14T23:23:10.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-08-23T23:13:56.000Z (almost 12 years ago)
- Last Synced: 2025-06-10T22:10:31.396Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 211 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# domstack
Stack your dom nodes outside of the main DOM tree.
## Installation
with [component](http://component.io):
$ component install bredele/domstack
with [nodejs](http://nodejs.org):
$ npm install domstack
## API
### Stack(parent)
Create a stack from a `root` dom element.
```js
var Stack = require('domstack');
var stack = new Stack(document.body);
```
### add(name, dom)
Add a node element into the stack.
```js
stack.add('first', node);
```
A stacked node is appended to a document fragment. Since a fragment is in memory and not part of the main DOM tree, computing one of its children does not cause reflow of repaint and results in better performance.
### show(name)
Display a stacked node into the `root` dom element.
```js
stack.show('first');
```
Only one stack child can be displayed at a time. However, you can asynchronously hide the current stack child as following:
```js
stack.show('first');
stack.show('second', function(done) {
// hide first
setTimeout(done, 3000);
});
```
## License
MIT