Comparing version 0.0.5 to 0.0.6
@@ -1,2 +0,2 @@ | ||
(function(n,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(n=typeof globalThis<"u"?globalThis:n||self,n.winkblue=r())})(this,function(){"use strict";const n=Object.create(null);return{on:function(t,o){const e=new WeakSet,f=new MutationObserver(()=>{for(const i of Array.from(document.querySelectorAll(t)))if(i&&!e.has(i))return e.add(i),setTimeout(()=>o(i),0)});f.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),n[t]||(n[t]=new Set),n[t].add({cb:o,mo:f})},off:function(t,o){const e=n[t];if(e)if(o){const f=Array.from(e).find(i=>i.cb===o);f.mo.disconnect(),e.delete(f)}else for(const f of e)f.mo.disconnect(),e.delete(f)},reset:function(){for(const t of Object.keys(n)){const o=n[t];for(const e of o)e.mo.disconnect(),o.delete(e)}}}}); | ||
(function(n,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(n=typeof globalThis<"u"?globalThis:n||self,n.winkblue=r())})(this,function(){"use strict";const n=Object.create(null);return{on:function(o,f){const e=new WeakSet,t=new MutationObserver(()=>{for(const i of Array.from(document.querySelectorAll(o)))i&&!e.has(i)&&(e.add(i),setTimeout(()=>f(i),0))});t.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),n[o]||(n[o]=new Set),n[o].add({cb:f,mo:t})},off:function(o,f){const e=n[o];if(e)if(f){const t=Array.from(e).find(i=>i.cb===f);if(!t)return;t.mo.disconnect(),e.delete(t)}else for(const t of e)t.mo.disconnect(),e.delete(t)},reset:function(){for(const o of Object.keys(n)){const f=n[o];for(const e of f)e.mo.disconnect(),f.delete(e)}}}}); | ||
//# sourceMappingURL=winkblue.umd.js.map |
{ | ||
"name": "winkblue", | ||
"type": "module", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
@@ -6,0 +6,0 @@ "author": "FlandreDaisuki <vbnm123c+github@gmail.com>", |
@@ -7,4 +7,36 @@ # winkblue | ||
## why? | ||
## Installation | ||
### CDN | ||
```html | ||
<script src="https://unpkg.com/winkblue@0.0.5/dist/winkblue.umd.js"></script> | ||
``` | ||
### CDN + ESM | ||
```html | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"winkblue": "https://esm.sh/winkblue" | ||
} | ||
} | ||
</script> | ||
<script type="module"> | ||
import winkblue from 'winkblue'; | ||
</script> | ||
``` | ||
## Usage | ||
```js | ||
winkblue.on('.dynamic-load-components', (el) => { | ||
// do something on `el` | ||
}); | ||
``` | ||
## Why? | ||
1. sentinel-js can not find the `display: none;` elements. | ||
@@ -14,4 +46,8 @@ 2. sentinel-js can not trigger multiple times if multiple selectors match the same element. | ||
## playground | ||
## Limitation | ||
1. if you reuse the same element instance, the callback will not be triggered. | ||
## Playground | ||
1. [simple usage](https://flandredaisuki.github.io/winkblue/play/simple) | ||
@@ -21,2 +57,4 @@ 2. [hidden elements](https://flandredaisuki.github.io/winkblue/play/hidden) | ||
4. [multiple instance](https://flandredaisuki.github.io/winkblue/play/multi-instance) | ||
5. [blink](https://flandredaisuki.github.io/winkblue/play/blink) | ||
6. [scattergun](https://flandredaisuki.github.io/winkblue/play/scattergun) | ||
@@ -23,0 +61,0 @@ ## LICENSE |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9995
45
61