mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: flashes
This commit is contained in:
1 parent
6d25a97fc8
commit
8446e3fbbd
2 files changed
+34
-1
No files matched your search
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#reload-visualizer-flash {
|
||||||
|
background: transparent;
|
||||||
|
transition-duration: 200ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
#reload-visualizer-flash.go {
|
||||||
|
background: var(--white-a3);
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
+25
-1
@@ -1,12 +1,13 @@
|
|||||||
import { Box, Code } from '@radix-ui/themes';
|
import { Box, Code } from '@radix-ui/themes';
|
||||||
import { times } from 'lodash-es';
|
import { times } from 'lodash-es';
|
||||||
import { Quicklime, type QuicklimeCallback } from 'quicklime';
|
import { Quicklime, type QuicklimeCallback } from 'quicklime';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useCallback, useEffect, useRef } from 'react';
|
||||||
import { Var } from '../../../../../../../core/radix/var';
|
import { Var } from '../../../../../../../core/radix/var';
|
||||||
import type { StatsAcceptorProps } from '../TraverseVisualizer';
|
import type { StatsAcceptorProps } from '../TraverseVisualizer';
|
||||||
import { VisualizerCard } from '../VisualizerCard';
|
import { VisualizerCard } from '../VisualizerCard';
|
||||||
import { Shell } from './components/Shell';
|
import { Shell } from './components/Shell';
|
||||||
import { Target } from './components/Target';
|
import { Target } from './components/Target';
|
||||||
|
import './index.css';
|
||||||
|
|
||||||
const PRECISION = 2;
|
const PRECISION = 2;
|
||||||
|
|
||||||
@@ -26,6 +27,16 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
|
|||||||
|
|
||||||
const state = useRef(0);
|
const state = useRef(0);
|
||||||
|
|
||||||
|
const shoot = useCallback(() => {
|
||||||
|
const element = document.getElementById('reload-visualizer-flash');
|
||||||
|
|
||||||
|
console.log('shoot');
|
||||||
|
|
||||||
|
element?.classList.add('go');
|
||||||
|
void element?.offsetWidth;
|
||||||
|
element?.classList.remove('go');
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancel = false;
|
let cancel = false;
|
||||||
let lastT = Date.now() / 1000;
|
let lastT = Date.now() / 1000;
|
||||||
@@ -66,6 +77,8 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
|
|||||||
progressTime.current.innerHTML = ((1 - reload) * shellReload).toFixed(
|
progressTime.current.innerHTML = ((1 - reload) * shellReload).toFixed(
|
||||||
PRECISION,
|
PRECISION,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (state.current >= reloadThreshold) shoot();
|
||||||
} else if (state.current < stats.shells + reloadThreshold - 1) {
|
} else if (state.current < stats.shells + reloadThreshold - 1) {
|
||||||
let interval;
|
let interval;
|
||||||
|
|
||||||
@@ -99,6 +112,8 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
|
|||||||
progressTime.current.innerHTML = ((1 - reload) * interval).toFixed(
|
progressTime.current.innerHTML = ((1 - reload) * interval).toFixed(
|
||||||
PRECISION,
|
PRECISION,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (lastState % 1 > state.current % 1) shoot();
|
||||||
} else {
|
} else {
|
||||||
state.current = 0;
|
state.current = 0;
|
||||||
reload = 0;
|
reload = 0;
|
||||||
@@ -264,6 +279,15 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
|
|||||||
times(stats.shells, (index) => (
|
times(stats.shells, (index) => (
|
||||||
<Shell stats={stats} index={index} key={index} />
|
<Shell stats={stats} index={index} key={index} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
<Box
|
||||||
|
id="reload-visualizer-flash"
|
||||||
|
position="absolute"
|
||||||
|
top="0"
|
||||||
|
left="0"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
/>
|
||||||
</VisualizerCard>
|
</VisualizerCard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user