add image scale type
This commit is contained in:
parent
65089091ec
commit
2f311f4c25
@ -1,8 +1,17 @@
|
|||||||
import { DoricViewNode, LEFT, RIGHT, CENTER_X, CENTER_Y, TOP, BOTTOM, toPixelString, toRGBAString } from "./DoricViewNode";
|
import { DoricViewNode, LEFT, RIGHT, CENTER_X, CENTER_Y, TOP, BOTTOM, toPixelString, toRGBAString } from "./DoricViewNode";
|
||||||
|
|
||||||
|
enum ScaleType {
|
||||||
|
ScaleToFill = 0,
|
||||||
|
ScaleAspectFit,
|
||||||
|
ScaleAspectFill,
|
||||||
|
}
|
||||||
|
|
||||||
export class DoricImageNode extends DoricViewNode {
|
export class DoricImageNode extends DoricViewNode {
|
||||||
|
|
||||||
build(): HTMLElement {
|
build(): HTMLElement {
|
||||||
return document.createElement('img')
|
const ret = document.createElement('img')
|
||||||
|
ret.style.objectFit = "fill"
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
blendProps(v: HTMLImageElement, propName: string, prop: any) {
|
blendProps(v: HTMLImageElement, propName: string, prop: any) {
|
||||||
@ -21,6 +30,19 @@ export class DoricImageNode extends DoricViewNode {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case 'scaleType':
|
||||||
|
switch (prop) {
|
||||||
|
case ScaleType.ScaleToFill:
|
||||||
|
v.style.objectFit = "fill"
|
||||||
|
break
|
||||||
|
case ScaleType.ScaleAspectFit:
|
||||||
|
v.style.objectFit = "contain"
|
||||||
|
break
|
||||||
|
case ScaleType.ScaleAspectFill:
|
||||||
|
v.style.objectFit = "cover"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
super.blendProps(v, propName, prop)
|
super.blendProps(v, propName, prop)
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user