From 92f47cc9cbb2aaa021f2c9925f3cbe283a20b84a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 22 Mar 2020 18:18:34 +0900 Subject: [PATCH] Remove smooth option to improve performance --- src/client/components/analog-clock.vue | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/client/components/analog-clock.vue b/src/client/components/analog-clock.vue index b68926678..81c6598c7 100644 --- a/src/client/components/analog-clock.vue +++ b/src/client/components/analog-clock.vue @@ -38,13 +38,6 @@ import Vue from 'vue'; import * as tinycolor from 'tinycolor2'; export default Vue.extend({ - props: { - smooth: { - type: Boolean, - default: false - } - }, - data() { return { now: new Date(), @@ -83,9 +76,6 @@ export default Vue.extend({ return tinycolor(this.computedStyle.getPropertyValue('--accent')).toHexString(); }, - ms(): number { - return this.now.getMilliseconds() * (this.smooth ? 1 : 0); - }, s(): number { return this.now.getSeconds(); }, @@ -97,13 +87,13 @@ export default Vue.extend({ }, hAngle(): number { - return Math.PI * (this.h % 12 + (this.m + (this.s + this.ms / 1000) / 60) / 60) / 6; + return Math.PI * (this.h % 12 + (this.m + this.s / 60) / 60) / 6; }, mAngle(): number { - return Math.PI * (this.m + (this.s + this.ms / 1000) / 60) / 30; + return Math.PI * (this.m + this.s / 60) / 30; }, sAngle(): number { - return Math.PI * (this.s + this.ms / 1000) / 30; + return Math.PI * this.s / 30; }, graduations(): any { @@ -121,7 +111,7 @@ export default Vue.extend({ const update = () => { if (this.enabled) { this.tick(); - requestAnimationFrame(update); + setTimeout(update, 1000); } }; update();