https://github.com/ayamflow/redraw-dom
Forces the browser to synchronously redraw a DOM node.
https://github.com/ayamflow/redraw-dom
Last synced: 11 months ago
JSON representation
Forces the browser to synchronously redraw a DOM node.
- Host: GitHub
- URL: https://github.com/ayamflow/redraw-dom
- Owner: ayamflow
- Created: 2015-07-02T09:18:55.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-02T09:20:21.000Z (almost 11 years ago)
- Last Synced: 2025-07-21T09:03:04.998Z (11 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
redraw-dom
===
Forces the browser to synchronously redraw a DOM node.
Anytime you've got some weird bug with the browsing not updatig the look of your element, you might need to force a repaint/redraw. This snippet will do the trick!
Before using this, you might want to try the `backface-visibility: hidden;` hack or using `will-change` (as seen [here](https://dev.opera.com/articles/css-will-change-property/)) since this is the "official" way to go.
## API
- `redraw(el, display)`
redraw the `el` element (must be a DOM node). `display` is the display style you want restored on the element (defaults to `block`).
## Example
```
var redraw = require('redraw-dom');
var el = document.querySelector('.el-redraw');
redraw(el);
el.style.display = 'inline';
redraw(el, 'inline'); // Preserve the inline display
```