diff --git a/doric-web/src/shader/DoricSwitchNode.ts b/doric-web/src/shader/DoricSwitchNode.ts index 99c0b4d9..e1d7fe28 100644 --- a/doric-web/src/shader/DoricSwitchNode.ts +++ b/doric-web/src/shader/DoricSwitchNode.ts @@ -33,31 +33,37 @@ export class DoricSwitchNode extends DoricViewNode { ret.appendChild(input) ret.appendChild(box) ret.onclick = () => { - if (input.checked === false) { - span.animate( - [{ transform: "translateX(30px)" }], { - duration: 200, - fill: "forwards" - }) - box.animate([{ backgroundColor: this.onTintColor }], { - duration: 200, - fill: "forwards" - }) - input.checked = true - } else { - span.animate([{ transform: "translateX(0px)" }], { - duration: 200, - fill: "forwards" - }) - box.animate([{ backgroundColor: this.offTintColor }], { - duration: 200, - fill: "forwards" - }) - input.checked = false - } - if (this.onSwitchFuncId) { - this.callJSResponse(this.onSwitchFuncId, input.checked) + try { + + if (input.checked === false) { + span.animate( + [{ transform: "translateX(0px)" }, { transform: "translateX(30px)" }], { + duration: 200, + fill: "forwards" + }) + box.animate([{ backgroundColor: this.offTintColor }, { backgroundColor: this.onTintColor }], { + duration: 200, + fill: "forwards" + }) + input.checked = true + } else { + span.animate([{ transform: "translateX(30px)" }, { transform: "translateX(0px)" }], { + duration: 200, + fill: "forwards" + }) + box.animate([{ backgroundColor: this.onTintColor }, { backgroundColor: this.offTintColor }], { + duration: 200, + fill: "forwards" + }) + input.checked = false + } + if (this.onSwitchFuncId) { + this.callJSResponse(this.onSwitchFuncId, input.checked) + } + } catch (e) { + alert(e) } + } this.input = input this.span = span