fix(frontend): confettiの実行がアニメーション設定を考慮していない問題を修正 (#16714)
* fix(frontend): confettiの実行がアニメーション設定を考慮していない問題を修正 * Update Changelog --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
parent
17da44078b
commit
4e16e23acd
|
|
@ -4,7 +4,7 @@
|
||||||
-
|
-
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
-
|
- Fix: 紙吹雪エフェクトがアニメーション設定を考慮せず常に表示される問題を修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
-
|
-
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,4 @@ export const instanceName = (siteName === 'Misskey' || siteName == null) ? host
|
||||||
export const ui = localStorage.getItem('ui');
|
export const ui = localStorage.getItem('ui');
|
||||||
export const debug = localStorage.getItem('debug') === 'true';
|
export const debug = localStorage.getItem('debug') === 'true';
|
||||||
export const isSafeMode = localStorage.getItem('isSafeMode') === 'true';
|
export const isSafeMode = localStorage.getItem('isSafeMode') === 'true';
|
||||||
|
export const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion)').matches;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { hemisphere } from '@@/js/intl-const.js';
|
import { hemisphere } from '@@/js/intl-const.js';
|
||||||
|
import { prefersReducedMotion } from '@@/js/config.js';
|
||||||
import { definePreferences } from './manager.js';
|
import { definePreferences } from './manager.js';
|
||||||
import type { Theme } from '@/theme.js';
|
import type { Theme } from '@/theme.js';
|
||||||
import type { SoundType } from '@/utility/sound.js';
|
import type { SoundType } from '@/utility/sound.js';
|
||||||
|
|
@ -211,10 +212,10 @@ export const PREF_DEF = definePreferences({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
animation: {
|
animation: {
|
||||||
default: !window.matchMedia('(prefers-reduced-motion)').matches,
|
default: !prefersReducedMotion,
|
||||||
},
|
},
|
||||||
animatedMfm: {
|
animatedMfm: {
|
||||||
default: !window.matchMedia('(prefers-reduced-motion)').matches,
|
default: !prefersReducedMotion,
|
||||||
},
|
},
|
||||||
advancedMfm: {
|
advancedMfm: {
|
||||||
default: true,
|
default: true,
|
||||||
|
|
@ -232,7 +233,7 @@ export const PREF_DEF = definePreferences({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
disableShowingAnimatedImages: {
|
disableShowingAnimatedImages: {
|
||||||
default: window.matchMedia('(prefers-reduced-motion)').matches,
|
default: prefersReducedMotion,
|
||||||
},
|
},
|
||||||
emojiStyle: {
|
emojiStyle: {
|
||||||
default: 'twemoji', // twemoji / fluentEmoji / native
|
default: 'twemoji', // twemoji / fluentEmoji / native
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { markRaw, ref } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import lightTheme from '@@/themes/l-light.json5';
|
import lightTheme from '@@/themes/l-light.json5';
|
||||||
import darkTheme from '@@/themes/d-green-lime.json5';
|
import darkTheme from '@@/themes/d-green-lime.json5';
|
||||||
|
import { prefersReducedMotion } from '@@/js/config.js';
|
||||||
import { hemisphere } from '@@/js/intl-const.js';
|
import { hemisphere } from '@@/js/intl-const.js';
|
||||||
import type { DeviceKind } from '@/utility/device-kind.js';
|
import type { DeviceKind } from '@/utility/device-kind.js';
|
||||||
import type { Plugin } from '@/plugin.js';
|
import type { Plugin } from '@/plugin.js';
|
||||||
|
|
@ -220,11 +221,11 @@ export const store = markRaw(new Pizzax('base', {
|
||||||
},
|
},
|
||||||
animation: {
|
animation: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: !window.matchMedia('(prefers-reduced-motion)').matches,
|
default: !prefersReducedMotion,
|
||||||
},
|
},
|
||||||
animatedMfm: {
|
animatedMfm: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: !window.matchMedia('(prefers-reduced-motion)').matches,
|
default: !prefersReducedMotion,
|
||||||
},
|
},
|
||||||
advancedMfm: {
|
advancedMfm: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
|
|
@ -248,7 +249,7 @@ export const store = markRaw(new Pizzax('base', {
|
||||||
},
|
},
|
||||||
disableShowingAnimatedImages: {
|
disableShowingAnimatedImages: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: window.matchMedia('(prefers-reduced-motion)').matches,
|
default: prefersReducedMotion,
|
||||||
},
|
},
|
||||||
emojiStyle: {
|
emojiStyle: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,21 @@
|
||||||
|
|
||||||
import _confetti from 'canvas-confetti';
|
import _confetti from 'canvas-confetti';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
import { prefer } from '@/preferences.js';
|
||||||
|
|
||||||
export function confetti(options: { duration?: number; } = {}) {
|
export function confetti(options: { duration?: number; } = {}) {
|
||||||
|
if (!prefer.s.animation) return;
|
||||||
|
|
||||||
const duration = options.duration ?? 1000 * 4;
|
const duration = options.duration ?? 1000 * 4;
|
||||||
const animationEnd = Date.now() + duration;
|
const animationEnd = Date.now() + duration;
|
||||||
const defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: os.claimZIndex('high') };
|
const defaults = {
|
||||||
|
startVelocity: 30,
|
||||||
|
spread: 360,
|
||||||
|
ticks: 60,
|
||||||
|
zIndex: os.claimZIndex('high'),
|
||||||
|
} satisfies _confetti.Options;
|
||||||
|
|
||||||
function randomInRange(min, max) {
|
function randomInRange(min: number, max: number) {
|
||||||
return Math.random() * (max - min) + min;
|
return Math.random() * (max - min) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue