web:compat some browser

This commit is contained in:
pengfei.zhou 2021-04-19 20:55:32 +08:00 committed by osborn
parent c54c4442b5
commit 03e3630d02

View File

@ -33,23 +33,25 @@ export class DoricSwitchNode extends DoricViewNode {
ret.appendChild(input)
ret.appendChild(box)
ret.onclick = () => {
try {
if (input.checked === false) {
span.animate(
[{ transform: "translateX(30px)" }], {
[{ transform: "translateX(0px)" }, { transform: "translateX(30px)" }], {
duration: 200,
fill: "forwards"
})
box.animate([{ backgroundColor: this.onTintColor }], {
box.animate([{ backgroundColor: this.offTintColor }, { backgroundColor: this.onTintColor }], {
duration: 200,
fill: "forwards"
})
input.checked = true
} else {
span.animate([{ transform: "translateX(0px)" }], {
span.animate([{ transform: "translateX(30px)" }, { transform: "translateX(0px)" }], {
duration: 200,
fill: "forwards"
})
box.animate([{ backgroundColor: this.offTintColor }], {
box.animate([{ backgroundColor: this.onTintColor }, { backgroundColor: this.offTintColor }], {
duration: 200,
fill: "forwards"
})
@ -58,6 +60,10 @@ export class DoricSwitchNode extends DoricViewNode {
if (this.onSwitchFuncId) {
this.callJSResponse(this.onSwitchFuncId, input.checked)
}
} catch (e) {
alert(e)
}
}
this.input = input
this.span = span