This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/src/shader/DoricImageNode.ts

30 lines
917 B
TypeScript
Raw Normal View History

2019-12-21 16:37:55 +08:00
import { DoricViewNode, LEFT, RIGHT, CENTER_X, CENTER_Y, TOP, BOTTOM, toPixelString, toRGBAString } from "./DoricViewNode";
export class DoricImageNode extends DoricViewNode {
build(): HTMLElement {
return document.createElement('img')
}
2019-12-21 18:13:46 +08:00
blendProps(v: HTMLImageElement, propName: string, prop: any) {
2019-12-21 16:37:55 +08:00
switch (propName) {
case 'imageUrl':
v.setAttribute('src', prop)
break
case 'imageBase64':
v.setAttribute('src', prop)
break
case 'loadCallback':
v.onload = () => {
2019-12-21 18:13:46 +08:00
this.callJSResponse(prop, {
width: v.width,
height: v.height
})
2019-12-21 16:37:55 +08:00
}
break
default:
super.blendProps(v, propName, prop)
break
}
}
}