Вот компонент:
Код: Выделить всё
"use client";
import { useState } from "react";
import { motion } from "framer-motion";
type Position = {
x: number;
y: number;
};
function BigBlockImage() {
const [isHovering, setIsHovering] = useState(false);
const [position, setPosition] = useState
({ x: 0, y: 0 });
return (
className="w-full aspect-video bg-placeholder relative cursor-none"
onMouseEnter={(e) => {
setIsHovering(true);
}}
onMouseLeave={(e) => {
setIsHovering(false);
}}
onMouseMove={(e) => {
const rect = e.target.getBoundingClientRect();
const x = e.clientX - rect.left - 57;
const y = e.clientY - rect.top - 57;
console.log(x, y);
setPosition({
x,
y,
});
}}
>
{isHovering && (
VIEW
)}
);
}
export default BigBlockImage;
Подробнее здесь: https://stackoverflow.com/questions/792 ... mer-motion
Мобильная версия