|
| 1 | +import code from '@/content/Animations/LaserFlow/LaserFlow.vue?raw'; |
| 2 | +import { createCodeObject } from '@/types/code'; |
| 3 | + |
| 4 | +export const laserFlow = createCodeObject(code, 'Animations/LaserFlow', { |
| 5 | + installation: `npm install three`, |
| 6 | + usage: `<template> |
| 7 | + <div |
| 8 | + style="height: 800px; position: relative; overflow: hidden; background-color: #060010;" |
| 9 | + @mousemove="handleMouseMove" |
| 10 | + @mouseleave="handleMouseLeave" |
| 11 | + > |
| 12 | + <LaserFlow |
| 13 | + :horizontalBeamOffset="0.1" |
| 14 | + :verticalBeamOffset="0.0" |
| 15 | + color="#FF79C6" |
| 16 | + /> |
| 17 | +
|
| 18 | + <div |
| 19 | + style=" |
| 20 | + position: absolute; |
| 21 | + top: 50%; |
| 22 | + left: 50%; |
| 23 | + transform: translateX(-50%); |
| 24 | + width: 86%; |
| 25 | + height: 60%; |
| 26 | + background-color: #060010; |
| 27 | + border-radius: 20px; |
| 28 | + border: 2px solid #FF79C6; |
| 29 | + display: flex; |
| 30 | + align-items: center; |
| 31 | + justify-content: center; |
| 32 | + color: white; |
| 33 | + font-size: 2rem; |
| 34 | + z-index: 6; |
| 35 | + " |
| 36 | + > |
| 37 | + <!-- Your content here --> |
| 38 | + Example Box Content |
| 39 | + </div> |
| 40 | +
|
| 41 | + <img |
| 42 | + ref="revealImgRef" |
| 43 | + src="/path/to/image.jpg" |
| 44 | + alt="Reveal effect" |
| 45 | + style=" |
| 46 | + position: absolute; |
| 47 | + width: 100%; |
| 48 | + top: -50%; |
| 49 | + z-index: 5; |
| 50 | + mix-blend-mode: lighten; |
| 51 | + opacity: 0.3; |
| 52 | + pointer-events: none; |
| 53 | + --mx: -9999px; |
| 54 | + --my: -9999px; |
| 55 | + -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), |
| 56 | + rgba(255,255,255,1) 0px, |
| 57 | + rgba(255,255,255,0.95) 60px, |
| 58 | + rgba(255,255,255,0.6) 120px, |
| 59 | + rgba(255,255,255,0.25) 180px, |
| 60 | + rgba(255,255,255,0) 240px); |
| 61 | + mask-image: radial-gradient(circle at var(--mx) var(--my), |
| 62 | + rgba(255,255,255,1) 0px, |
| 63 | + rgba(255,255,255,0.95) 60px, |
| 64 | + rgba(255,255,255,0.6) 120px, |
| 65 | + rgba(255,255,255,0.25) 180px, |
| 66 | + rgba(255,255,255,0) 240px); |
| 67 | + -webkit-mask-repeat: no-repeat; |
| 68 | + mask-repeat: no-repeat; |
| 69 | + " |
| 70 | + /> |
| 71 | + </div> |
| 72 | +</template> |
| 73 | +
|
| 74 | +<script setup> |
| 75 | +import { useTemplateRef } from 'vue' |
| 76 | +import LaserFlow from './LaserFlow.vue' |
| 77 | +
|
| 78 | +const revealImgRef = useTemplateRef('revealImgRef') |
| 79 | +
|
| 80 | +function handleMouseMove(e) { |
| 81 | + const rect = e.currentTarget.getBoundingClientRect() |
| 82 | + const x = e.clientX - rect.left |
| 83 | + const y = e.clientY - rect.top |
| 84 | + const el = revealImgRef.value |
| 85 | + if (el) { |
| 86 | + el.style.setProperty('--mx', '\${x}px') |
| 87 | + el.style.setProperty('--my', '\${y + rect.height * 0.5}px') |
| 88 | + } |
| 89 | +} |
| 90 | +
|
| 91 | +function handleMouseLeave() { |
| 92 | + const el = revealImgRef.value |
| 93 | + if (el) { |
| 94 | + el.style.setProperty('--mx', '-9999px') |
| 95 | + el.style.setProperty('--my', '-9999px') |
| 96 | + } |
| 97 | +} |
| 98 | +</script>` |
| 99 | +}); |
0 commit comments