Skip to content

Commit

Permalink
feat(runner)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamadreza1388 committed Jan 11, 2025
1 parent 7ca894f commit b9a2e79
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/components/editor/Runner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@ import {useEffect, useState} from "react";
const Runner = () => {
const [hidden, setHidden] = useState(true);

useEffect(() => {
document.addEventListener("keydown", (e) => {
if (e.altKey && e.code === 'F2') {
e.preventDefault();
alert('شما ترکیب Alt + F2 را فشردید!');
function debounce(cb, delay) {
let timeoutId;
return function (...args) {
if (timeoutId) {
clearTimeout(timeoutId);
}

timeoutId = setTimeout(() => {
cb(...args);
}, delay);
};
}

const debouncedChange = debounce(() => {
setHidden(true)
}, 2000);

useEffect(() => {
document.addEventListener("mousemove", (e) => {
e.preventDefault();
setHidden(false)

debouncedChange();
})
}, [])

return(<>
<div className={(hidden && "hidden ") + " fixed top-[75px] left-[70px] z-[998] bg-white w-[100px] h-[35px] rounded-[10px] border"}></div>

return (<>
<div
className={(hidden && "opacity-0 ") + " fixed top-[75px] transition-all duration-500 left-[70px] z-[998] bg-white w-[100px] h-[40px] rounded-[10px] border"}></div>
</>)
}

Expand Down

0 comments on commit b9a2e79

Please sign in to comment.