diff options
| author | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2023-04-13 12:20:39 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-13 12:20:39 +0900 |
| commit | 9bb6c536c0cdf6c5fa5e9bda7ceba36f007ef4eb (patch) | |
| tree | 43682137b867ebc3dddc3a12e3bb5f50098f4f56 /packages/frontend/src/components/MkAnalogClock.vue | |
| parent | [ci skip] improve readability (diff) | |
| download | sharkey-9bb6c536c0cdf6c5fa5e9bda7ceba36f007ef4eb.tar.gz sharkey-9bb6c536c0cdf6c5fa5e9bda7ceba36f007ef4eb.tar.bz2 sharkey-9bb6c536c0cdf6c5fa5e9bda7ceba36f007ef4eb.zip | |
test(#10336): add `components/Mk[A-B].*` stories (#10475)
* chore(#10336): register snippets
* test(#10336): add `components/Mk[A-B].*` stories
* build: desynced lockfile
* ci(#10336): preload assets
* ci(#10336): use pull_request
* build: update lockfile
* fix: reactivity transform
* chore: track upstream changes
* refactor: avoid temporary previous tapping declarations
* revert: avoid temporary previous tapping declarations
This reverts commit e649b1b1e6771bee674f2dfb044e0efd72d0be5d.
* test: flaky snapshots
* style: import
Diffstat (limited to 'packages/frontend/src/components/MkAnalogClock.vue')
| -rw-r--r-- | packages/frontend/src/components/MkAnalogClock.vue | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/frontend/src/components/MkAnalogClock.vue b/packages/frontend/src/components/MkAnalogClock.vue index 1218202616..f12020f810 100644 --- a/packages/frontend/src/components/MkAnalogClock.vue +++ b/packages/frontend/src/components/MkAnalogClock.vue @@ -99,6 +99,7 @@ const props = withDefaults(defineProps<{ graduations?: 'none' | 'dots' | 'numbers'; fadeGraduations?: boolean; sAnimation?: 'none' | 'elastic' | 'easeOut'; + now?: () => Date; }>(), { numbers: false, thickness: 0.1, @@ -107,6 +108,7 @@ const props = withDefaults(defineProps<{ graduations: 'dots', fadeGraduations: true, sAnimation: 'elastic', + now: () => new Date(), }); const graduationsMajor = computed(() => { @@ -145,11 +147,17 @@ let disableSAnimate = $ref(false); let sOneRound = false; function tick() { - const now = new Date(); - now.setMinutes(now.getMinutes() + (new Date().getTimezoneOffset() + props.offset)); + const now = props.now(); + now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + props.offset); + const previousS = s; + const previousM = m; + const previousH = h; s = now.getSeconds(); m = now.getMinutes(); h = now.getHours(); + if (previousS === s && previousM === m && previousH === h) { + return; + } hAngle = Math.PI * (h % (props.twentyfour ? 24 : 12) + (m + s / 60) / 60) / (props.twentyfour ? 12 : 6); mAngle = Math.PI * (m + s / 60) / 30; if (sOneRound) { // 秒針が一周した際のアニメーションをよしなに処理する(これが無いと秒が59->0になったときに期待したアニメーションにならない) |