This commit is contained in:
ThatOneCalculator 2022-11-29 18:25:37 -08:00
parent eba3e97550
commit d72d5f3f49
3 changed files with 32 additions and 29 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "calckey", "name": "calckey",
"version": "12.119.0-calc.18-rc.1", "version": "12.119.0-calc.18-rc.2",
"codename": "aqua", "codename": "aqua",
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -71,38 +71,41 @@ const el = ref<HTMLElement>();
const width = ref(0); const width = ref(0);
const height = ref(0); const height = ref(0);
const colors = ['#eb6f92', '#9ccfd8', '#f6c177', '#f6c177', '#f6c177']; const colors = ['#eb6f92', '#9ccfd8', '#f6c177', '#f6c177', '#f6c177'];
const reducedQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
let stop = false; let stop = false;
let ro: ResizeObserver | undefined; let ro: ResizeObserver | undefined;
onMounted(() => { onMounted(() => {
ro = new ResizeObserver((entries, observer) => { if (!reducedQuery.matches) {
width.value = el.value?.offsetWidth + 64; ro = new ResizeObserver((entries, observer) => {
height.value = el.value?.offsetHeight + 64; width.value = el.value?.offsetWidth + 64;
}); height.value = el.value?.offsetHeight + 64;
ro.observe(el.value); });
const add = () => { ro.observe(el.value);
if (stop) return; const add = () => {
const x = (Math.random() * (width.value - 64)); if (stop) return;
const y = (Math.random() * (height.value - 64)); const x = (Math.random() * (width.value - 64));
const sizeFactor = Math.random(); const y = (Math.random() * (height.value - 64));
const particle = { const sizeFactor = Math.random();
id: Math.random().toString(), const particle = {
x, id: Math.random().toString(),
y, x,
size: 0.2 + ((sizeFactor / 10) * 3), y,
dur: 1000 + (sizeFactor * 1000), size: 0.2 + ((sizeFactor / 10) * 3),
color: colors[Math.floor(Math.random() * colors.length)], dur: 1000 + (sizeFactor * 1000),
}; color: colors[Math.floor(Math.random() * colors.length)],
particles.value.push(particle); };
window.setTimeout(() => { particles.value.push(particle);
particles.value = particles.value.filter(x => x.id !== particle.id); window.setTimeout(() => {
}, particle.dur - 100); particles.value = particles.value.filter(x => x.id !== particle.id);
}, particle.dur - 100);
window.setTimeout(() => { window.setTimeout(() => {
add(); add();
}, 500 + (Math.random() * 500)); }, 500 + (Math.random() * 500));
}; };
add(); add();
}
}); });
onUnmounted(() => { onUnmounted(() => {

View file

@ -158,7 +158,7 @@ const props = withDefaults(defineProps<{
} }
@media(prefers-reduced-motion) { @media(prefers-reduced-motion) {
div[class^='mfm'], div[class*=' mfm'] { span[class^='mfm'], div[class*=' mfm'] {
animation: none; animation: none;
} }
} }