mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 22:49:31 -07:00
Small tweaks
This commit is contained in:
@@ -27,7 +27,7 @@ const handleColorChange = (event: Event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.color-label {
|
.color-label {
|
||||||
font-size: 0.875rem;
|
font-size: 14px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ export const crosshair: CodeObject = {
|
|||||||
const containerElement = computed(() => containerRef.value);
|
const containerElement = computed(() => containerRef.value);
|
||||||
</script>`,
|
</script>`,
|
||||||
code
|
code
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ export const dither: CodeObject = {
|
|||||||
import Dither from "./Dither.vue";
|
import Dither from "./Dither.vue";
|
||||||
</script>`,
|
</script>`,
|
||||||
code
|
code
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,21 +22,11 @@
|
|||||||
>
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<filter id="filter-noise-x">
|
<filter id="filter-noise-x">
|
||||||
<feTurbulence
|
<feTurbulence type="fractalNoise" baseFrequency="0.000001" numOctaves="1" ref="filterXRef" />
|
||||||
type="fractalNoise"
|
|
||||||
baseFrequency="0.000001"
|
|
||||||
numOctaves="1"
|
|
||||||
ref="filterXRef"
|
|
||||||
/>
|
|
||||||
<feDisplacementMap in="SourceGraphic" scale="40" />
|
<feDisplacementMap in="SourceGraphic" scale="40" />
|
||||||
</filter>
|
</filter>
|
||||||
<filter id="filter-noise-y">
|
<filter id="filter-noise-y">
|
||||||
<feTurbulence
|
<feTurbulence type="fractalNoise" baseFrequency="0.000001" numOctaves="1" ref="filterYRef" />
|
||||||
type="fractalNoise"
|
|
||||||
baseFrequency="0.000001"
|
|
||||||
numOctaves="1"
|
|
||||||
ref="filterYRef"
|
|
||||||
/>
|
|
||||||
<feDisplacementMap in="SourceGraphic" scale="40" />
|
<feDisplacementMap in="SourceGraphic" scale="40" />
|
||||||
</filter>
|
</filter>
|
||||||
</defs>
|
</defs>
|
||||||
@@ -215,9 +205,7 @@ onMounted(() => {
|
|||||||
animationId = requestAnimationFrame(render);
|
animationId = requestAnimationFrame(render);
|
||||||
};
|
};
|
||||||
|
|
||||||
const links = props.containerRef
|
const links = props.containerRef ? props.containerRef.querySelectorAll('a') : document.querySelectorAll('a');
|
||||||
? props.containerRef.querySelectorAll('a')
|
|
||||||
: document.querySelectorAll('a');
|
|
||||||
|
|
||||||
links.forEach((link: HTMLAnchorElement) => {
|
links.forEach((link: HTMLAnchorElement) => {
|
||||||
link.addEventListener('mouseenter', enter);
|
link.addEventListener('mouseenter', enter);
|
||||||
@@ -227,12 +215,12 @@ onMounted(() => {
|
|||||||
cleanup = () => {
|
cleanup = () => {
|
||||||
target.removeEventListener('mousemove', handleMouseMove);
|
target.removeEventListener('mousemove', handleMouseMove);
|
||||||
target.removeEventListener('mousemove', onMouseMove);
|
target.removeEventListener('mousemove', onMouseMove);
|
||||||
|
|
||||||
if (animationId !== null) {
|
if (animationId !== null) {
|
||||||
cancelAnimationFrame(animationId);
|
cancelAnimationFrame(animationId);
|
||||||
animationId = null;
|
animationId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
links.forEach((link: HTMLAnchorElement) => {
|
links.forEach((link: HTMLAnchorElement) => {
|
||||||
link.removeEventListener('mouseenter', enter);
|
link.removeEventListener('mouseenter', enter);
|
||||||
link.removeEventListener('mouseleave', leave);
|
link.removeEventListener('mouseleave', leave);
|
||||||
@@ -246,4 +234,4 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -244,16 +244,19 @@ const handleMouseMove = (e: MouseEvent) => {
|
|||||||
if (!containerRef.value || !gl) return;
|
if (!containerRef.value || !gl) return;
|
||||||
|
|
||||||
const rect = containerRef.value.getBoundingClientRect();
|
const rect = containerRef.value.getBoundingClientRect();
|
||||||
const dpr = window.devicePixelRatio || 1;
|
|
||||||
const x = (e.clientX - rect.left) * dpr;
|
const normalizedX = (e.clientX - rect.left) / rect.width;
|
||||||
const y = (e.clientY - rect.top) * dpr;
|
const normalizedY = (e.clientY - rect.top) / rect.height;
|
||||||
|
|
||||||
|
const x = normalizedX * gl.canvas.width;
|
||||||
|
const y = normalizedY * gl.canvas.height;
|
||||||
|
|
||||||
targetMouse = [x, y];
|
targetMouse = [x, y];
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseLeave = () => {
|
const handleMouseLeave = () => {
|
||||||
if (!gl) return;
|
if (!gl) return;
|
||||||
const dpr = window.devicePixelRatio || 1;
|
targetMouse = [gl.canvas.width / 2, gl.canvas.height / 2];
|
||||||
targetMouse = [gl.canvas.width / (2 * dpr), gl.canvas.height / (2 * dpr)];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const update = (t: number) => {
|
const update = (t: number) => {
|
||||||
@@ -267,16 +270,15 @@ const update = (t: number) => {
|
|||||||
program.uniforms.mousePos.value[1] = currentMouse[1];
|
program.uniforms.mousePos.value[1] = currentMouse[1];
|
||||||
} else {
|
} else {
|
||||||
if (gl) {
|
if (gl) {
|
||||||
const dpr = window.devicePixelRatio || 1;
|
program.uniforms.mousePos.value[0] = gl.canvas.width / 2;
|
||||||
program.uniforms.mousePos.value[0] = gl.canvas.width / (2 * dpr);
|
program.uniforms.mousePos.value[1] = gl.canvas.height / 2;
|
||||||
program.uniforms.mousePos.value[1] = gl.canvas.height / (2 * dpr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!props.disableAnimation) {
|
if (!props.disableAnimation) {
|
||||||
program.uniforms.time.value = t * 0.001;
|
program.uniforms.time.value = t * 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
program.uniforms.waveSpeed.value = props.waveSpeed;
|
program.uniforms.waveSpeed.value = props.waveSpeed;
|
||||||
program.uniforms.waveFrequency.value = props.waveFrequency;
|
program.uniforms.waveFrequency.value = props.waveFrequency;
|
||||||
program.uniforms.waveAmplitude.value = props.waveAmplitude;
|
program.uniforms.waveAmplitude.value = props.waveAmplitude;
|
||||||
|
|||||||
@@ -28,17 +28,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewColor title="Crosshair Color" v-model="color" />
|
<PreviewSelect
|
||||||
|
title="Target"
|
||||||
|
:options="[
|
||||||
|
{ label: 'Container', value: 'targeted' },
|
||||||
|
{ label: 'Viewport', value: 'viewport' }
|
||||||
|
]"
|
||||||
|
v-model="targetedMode"
|
||||||
|
/>
|
||||||
|
|
||||||
<button
|
<PreviewColor title="Crosshair Color" v-model="color" />
|
||||||
class="bg-[#170D27] hover:bg-[#271E37] text-white text-xs px-3 py-2 border border-[#271E37] rounded-[10px] h-8 transition-colors mt-2"
|
|
||||||
@click="toggleTargeted"
|
|
||||||
>
|
|
||||||
Cursor Container
|
|
||||||
<span :class="targeted ? 'text-green-400' : 'text-orange-400'">
|
|
||||||
{{ targeted ? 'Viewport' : 'Targeted' }}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
@@ -64,6 +63,8 @@ import CliInstallation from '@/components/code/CliInstallation.vue';
|
|||||||
import CodeExample from '@/components/code/CodeExample.vue';
|
import CodeExample from '@/components/code/CodeExample.vue';
|
||||||
import Customize from '@/components/common/Customize.vue';
|
import Customize from '@/components/common/Customize.vue';
|
||||||
import PreviewColor from '@/components/common/PreviewColor.vue';
|
import PreviewColor from '@/components/common/PreviewColor.vue';
|
||||||
|
import PreviewSelect from '@/components/common/PreviewSelect.vue';
|
||||||
|
|
||||||
import Crosshair from '@/content/Animations/Crosshair/Crosshair.vue';
|
import Crosshair from '@/content/Animations/Crosshair/Crosshair.vue';
|
||||||
import { crosshair } from '@/constants/code/Animations/crosshairCode';
|
import { crosshair } from '@/constants/code/Animations/crosshairCode';
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ const DEFAULT_TEXT = 'Aim... aand...';
|
|||||||
|
|
||||||
const linkText = ref(DEFAULT_TEXT);
|
const linkText = ref(DEFAULT_TEXT);
|
||||||
const color = ref('#ffffff');
|
const color = ref('#ffffff');
|
||||||
const targeted = ref(true);
|
const targetedMode = ref('targeted');
|
||||||
const minWidth = ref(0);
|
const minWidth = ref(0);
|
||||||
|
|
||||||
const containerRef = useTemplateRef<HTMLDivElement>('containerRef');
|
const containerRef = useTemplateRef<HTMLDivElement>('containerRef');
|
||||||
@@ -79,6 +80,7 @@ const linkRef = useTemplateRef<HTMLAnchorElement>('linkRef');
|
|||||||
const hiddenRef = useTemplateRef<HTMLSpanElement>('hiddenRef');
|
const hiddenRef = useTemplateRef<HTMLSpanElement>('hiddenRef');
|
||||||
|
|
||||||
const containerElement = computed(() => containerRef.value);
|
const containerElement = computed(() => containerRef.value);
|
||||||
|
const targeted = computed(() => targetedMode.value === 'targeted');
|
||||||
|
|
||||||
const propData = [
|
const propData = [
|
||||||
{
|
{
|
||||||
@@ -91,7 +93,8 @@ const propData = [
|
|||||||
name: 'containerRef',
|
name: 'containerRef',
|
||||||
type: 'Ref<HTMLElement | null>',
|
type: 'Ref<HTMLElement | null>',
|
||||||
default: 'null',
|
default: 'null',
|
||||||
description: 'Optional container ref to limit crosshair to specific element. If null, crosshair will be active on entire viewport.'
|
description:
|
||||||
|
'Optional container ref to limit crosshair to specific element. If null, crosshair will be active on entire viewport.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -103,10 +106,6 @@ const handleMouseLeave = () => {
|
|||||||
linkText.value = DEFAULT_TEXT;
|
linkText.value = DEFAULT_TEXT;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleTargeted = () => {
|
|
||||||
targeted.value = !targeted.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateMinWidth = async () => {
|
const updateMinWidth = async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (hiddenRef.value) {
|
if (hiddenRef.value) {
|
||||||
@@ -137,4 +136,4 @@ onUnmounted(() => {
|
|||||||
resizeObserver.disconnect();
|
resizeObserver.disconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -73,18 +73,28 @@ import Dither from '../../content/Backgrounds/Dither/Dither.vue';
|
|||||||
|
|
||||||
const { rerenderKey, forceRerender } = useForceRerender();
|
const { rerenderKey, forceRerender } = useForceRerender();
|
||||||
|
|
||||||
const waveSpeed = ref(0.05);
|
const waveSpeed = ref(0.1);
|
||||||
const waveFrequency = ref(3);
|
const waveFrequency = ref(2.5);
|
||||||
const waveAmplitude = ref(0.3);
|
const waveAmplitude = ref(0.2);
|
||||||
const waveColor = ref<[number, number, number]>([0.5, 0.5, 0.5]);
|
const waveColor = ref<[number, number, number]>([0.1, 0.7, 0.5]);
|
||||||
const colorNum = ref(4);
|
const colorNum = ref(4);
|
||||||
const pixelSize = ref(2);
|
const pixelSize = ref(3);
|
||||||
const disableAnimation = ref(false);
|
const disableAnimation = ref(false);
|
||||||
const enableMouseInteraction = ref(true);
|
const enableMouseInteraction = ref(true);
|
||||||
const mouseRadius = ref(1);
|
const mouseRadius = ref(0.5);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[waveSpeed, waveFrequency, waveAmplitude, waveColor, colorNum, pixelSize, disableAnimation, enableMouseInteraction, mouseRadius],
|
[
|
||||||
|
waveSpeed,
|
||||||
|
waveFrequency,
|
||||||
|
waveAmplitude,
|
||||||
|
waveColor,
|
||||||
|
colorNum,
|
||||||
|
pixelSize,
|
||||||
|
disableAnimation,
|
||||||
|
enableMouseInteraction,
|
||||||
|
mouseRadius
|
||||||
|
],
|
||||||
() => {
|
() => {
|
||||||
forceRerender();
|
forceRerender();
|
||||||
},
|
},
|
||||||
@@ -147,4 +157,4 @@ const propData = [
|
|||||||
description: 'Radius of the mouse interaction effect.'
|
description: 'Radius of the mouse interaction effect.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user