mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-09 00:19:31 -06:00
Small tweaks
This commit is contained in:
@@ -22,21 +22,11 @@
|
||||
>
|
||||
<defs>
|
||||
<filter id="filter-noise-x">
|
||||
<feTurbulence
|
||||
type="fractalNoise"
|
||||
baseFrequency="0.000001"
|
||||
numOctaves="1"
|
||||
ref="filterXRef"
|
||||
/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="0.000001" numOctaves="1" ref="filterXRef" />
|
||||
<feDisplacementMap in="SourceGraphic" scale="40" />
|
||||
</filter>
|
||||
<filter id="filter-noise-y">
|
||||
<feTurbulence
|
||||
type="fractalNoise"
|
||||
baseFrequency="0.000001"
|
||||
numOctaves="1"
|
||||
ref="filterYRef"
|
||||
/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="0.000001" numOctaves="1" ref="filterYRef" />
|
||||
<feDisplacementMap in="SourceGraphic" scale="40" />
|
||||
</filter>
|
||||
</defs>
|
||||
@@ -215,9 +205,7 @@ onMounted(() => {
|
||||
animationId = requestAnimationFrame(render);
|
||||
};
|
||||
|
||||
const links = props.containerRef
|
||||
? props.containerRef.querySelectorAll('a')
|
||||
: document.querySelectorAll('a');
|
||||
const links = props.containerRef ? props.containerRef.querySelectorAll('a') : document.querySelectorAll('a');
|
||||
|
||||
links.forEach((link: HTMLAnchorElement) => {
|
||||
link.addEventListener('mouseenter', enter);
|
||||
@@ -227,12 +215,12 @@ onMounted(() => {
|
||||
cleanup = () => {
|
||||
target.removeEventListener('mousemove', handleMouseMove);
|
||||
target.removeEventListener('mousemove', onMouseMove);
|
||||
|
||||
|
||||
if (animationId !== null) {
|
||||
cancelAnimationFrame(animationId);
|
||||
animationId = null;
|
||||
}
|
||||
|
||||
|
||||
links.forEach((link: HTMLAnchorElement) => {
|
||||
link.removeEventListener('mouseenter', enter);
|
||||
link.removeEventListener('mouseleave', leave);
|
||||
@@ -246,4 +234,4 @@ onMounted(() => {
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -244,16 +244,19 @@ const handleMouseMove = (e: MouseEvent) => {
|
||||
if (!containerRef.value || !gl) return;
|
||||
|
||||
const rect = containerRef.value.getBoundingClientRect();
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
const x = (e.clientX - rect.left) * dpr;
|
||||
const y = (e.clientY - rect.top) * dpr;
|
||||
|
||||
const normalizedX = (e.clientX - rect.left) / rect.width;
|
||||
const normalizedY = (e.clientY - rect.top) / rect.height;
|
||||
|
||||
const x = normalizedX * gl.canvas.width;
|
||||
const y = normalizedY * gl.canvas.height;
|
||||
|
||||
targetMouse = [x, y];
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
if (!gl) return;
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
targetMouse = [gl.canvas.width / (2 * dpr), gl.canvas.height / (2 * dpr)];
|
||||
targetMouse = [gl.canvas.width / 2, gl.canvas.height / 2];
|
||||
};
|
||||
|
||||
const update = (t: number) => {
|
||||
@@ -267,16 +270,15 @@ const update = (t: number) => {
|
||||
program.uniforms.mousePos.value[1] = currentMouse[1];
|
||||
} else {
|
||||
if (gl) {
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
program.uniforms.mousePos.value[0] = gl.canvas.width / (2 * dpr);
|
||||
program.uniforms.mousePos.value[1] = gl.canvas.height / (2 * dpr);
|
||||
program.uniforms.mousePos.value[0] = gl.canvas.width / 2;
|
||||
program.uniforms.mousePos.value[1] = gl.canvas.height / 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!props.disableAnimation) {
|
||||
program.uniforms.time.value = t * 0.001;
|
||||
}
|
||||
|
||||
|
||||
program.uniforms.waveSpeed.value = props.waveSpeed;
|
||||
program.uniforms.waveFrequency.value = props.waveFrequency;
|
||||
program.uniforms.waveAmplitude.value = props.waveAmplitude;
|
||||
|
||||
Reference in New Issue
Block a user