add shadow effects

This commit is contained in:
pengfei.zhou 2019-12-21 18:04:12 +08:00
parent adf0077759
commit 0ac97353f2
3 changed files with 28 additions and 1 deletions

14
dist/index.js vendored
View File

@ -3856,6 +3856,20 @@ return __module.exports;
this.view.style.borderRadius = toPixelString(prop); this.view.style.borderRadius = toPixelString(prop);
} }
break; break;
case 'shadow':
const opacity = prop.opacity || 0;
if (opacity > 0) {
const offsetX = prop.offsetX || 0;
const offsetY = prop.offsetY || 0;
const shadowColor = prop.color || 0xff000000;
const shadowRadius = prop.radius;
const alpha = opacity * 255;
this.view.style.boxShadow = `${toPixelString(offsetX)} ${toPixelString(offsetY)} ${toPixelString(shadowRadius)} ${toRGBAString((shadowColor & 0xffffff) | ((alpha & 0xff) << 24))} `;
}
else {
this.view.style.boxShadow = "";
}
break;
} }
} }
set backgroundColor(v) { set backgroundColor(v) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -259,6 +259,19 @@ export abstract class DoricViewNode {
this.view.style.borderRadius = toPixelString(prop) this.view.style.borderRadius = toPixelString(prop)
} }
break break
case 'shadow':
const opacity = prop.opacity || 0
if (opacity > 0) {
const offsetX = prop.offsetX || 0
const offsetY = prop.offsetY || 0
const shadowColor = prop.color || 0xff000000
const shadowRadius = prop.radius
const alpha = opacity * 255
this.view.style.boxShadow = `${toPixelString(offsetX)} ${toPixelString(offsetY)} ${toPixelString(shadowRadius)} ${toRGBAString((shadowColor & 0xffffff) | ((alpha & 0xff) << 24))} `
} else {
this.view.style.boxShadow = ""
}
break
} }
} }