0.1.13 • Published 1 year ago

vanilla-life v0.1.13

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

vanilla-life

Size < 1kb

给 Element 添加关键的生命周期

Install

$ npm install --save vanilla-life

Use

为 Element 添加一次性的生命周期(触发即移除监听)

import { onAppend, onRemove, onLazy } from "vanilla-life";

const out = document.createElement("div");

onRemove(out, () => console.log("out已从页面中移除"));
onEntry(out, () => console.log("out已从屏幕外面进入到屏幕中"));
onAppend(out, () => console.log("out已插入到页面中"));

// 注意以上生命周期都需要在元素在 append 之前声明
document.body.append(out);

Tree

类似 JSX 的树型函数来创建 DOM 树

import { tree, treeUpdate } from "vanilla-life";

tree(document.createElement("div"), {
  className: "contains",
	cssText:"width:100%; height:100%;"
	onclick:()=>{
   alert("hello")
	},
	append:[
		"Hello",
		tree(document.createElement("span"), {
			innerText:"world",
			cssText:"color:red;"
		}),
		tree(document.createElement("span"))
	]
});
0.1.12

1 year ago

0.1.13

1 year ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago