Dirty

Micro library for handling dirty DOM updates frame-by-frame.
Usage
import { DirtyType, EventType, UpdateDelegate } from '@andrewscwei/dirty';
class Foo {
get bar() {
return this._bar;
}
set bar(newValue) {
this._bar = newValue;
this.updateDelegate.setDirty(DirtyType.LAYOUT);
}
constructor {
updateDelegate = new UpdateDelegate(this, {
[EventType.ENTER_FRAME]: true,
[EventType.RESIZE]: 10,
[EventType.ORIENTATION_CHANGE]: 0,
[EventType.SCROLL]: {
target: document.getElementById('foo'),
refreshRate: 10,
},
[EventType.MOUSE_WHEEL]: true,
[EventType.MOUSE_MOVE]: true,
[EventType.KEY_UP]: true,
[EventType.KEY_DOWN]: true,
[EventType.KEY_PRESS]: true,
});
}
deinit() {
this.updateDelegate.destroy();
}
update(info) {
if (info[DirtyType.POSITION]) {
console.log(info[DirtyType.POSITION]);
}
if (info[DirtyType.SIZE]) {
console.log(info[DirtyType.SIZE]);
}
if (info[DirtyType.LAYOUT]) {
}
if (info[DirtyType.STATE]) {
}
if (info[DirtyType.DATA]) {
}
if (info[DirtyType.LOCALE]) {
}
if (info[DirtyType.CONFIG]) {
}
if (info[DirtyType.STYLE]) {
}
if (info[DirtyType.INPUT]) {
console.log(info[DirtyType.INPUT]);
}
if (info[DirtyType.ORIENTATION]) {
console.log(info[DirtyType.ORIENTATION]);
}
if (info[DirtyType.FRAME]) {
}
}
Release Notes
v3.0.0
- BREAKING: Dirty info API for
DirtyType.INPUT
changed. Instead of mouseX
, mouseY
, mouseWheelX
and mouseWheelY
, it's now just mouse
and mousewheel
where each is an instance of Point
.
v2.0.0
UpdateDelegate
no longer starts automatically, you must manually invoke init()
- Added
ScrollDelegate
and CrossScrollDelegate
- Added dirty info for
DirtyType.POSITION
and DirtyType.SIZE