https://github.com/bahrus/lazy-mt
https://github.com/bahrus/lazy-mt
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bahrus/lazy-mt
- Owner: bahrus
- License: mit
- Created: 2021-03-05T12:43:57.000Z (about 4 years ago)
- Default Branch: baseline
- Last Pushed: 2021-10-06T11:49:53.000Z (over 3 years ago)
- Last Synced: 2025-02-01T00:19:33.828Z (4 months ago)
- Language: TypeScript
- Size: 652 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lazy-mt
lazy-mt ("lazy mount") is an alternative to [laissez-dom](https://github.com/bahrus/laissez-dom). Like laissez-dom, it is assumed that some taxing content should only be added to the live DOM-tree when it becomes necessary -- namely when it becomes visible. And optionally it should go to sleep (become disabled) when it rolls out of view. Unlike laissez-dom, the "mt" DOM content (hee haw haw) tucked inside the template is expected to be sandwiched between two instances of lazy-mt:
```html
```
When either the enter or exit instance becomes visible, the template is cloned between the two tags (and the template is discarded).
Attribute "mount" is required in order to start watching for visibility.
When both lazy-mt tags leave the viewport, lazy-mt can set any elements to disabled, if attribute/property toggle-disabled/toggleDisabled is set/true. So what you will see is:
```html
```
when either of the lazy-mt's lose visibility.
If attribute/property min-mem/minMem is set/true, then rather than discarding the template, it is held in memory, and the inner contents is deleted when both "bookends" lose visibility. This allows the inner content to be restored when it comes back in view (but state may be lost with this approach, so a strategy must be developed to restore state in this scenario).