Skip to content

Commit

Permalink
Add request pointer lock support
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Jan 6, 2025
1 parent 23ad1d2 commit 0e8a0e5
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,11 @@ export const CssValueInput = ({
signal: abortController.signal,
};

let focusValue = null;
let focusTime = 0;
inputRef.current.addEventListener(
"selectionchange",
() => {
if (Date.now() - focusTime < 50) {
console.log("select");
inputRef.current?.select();
}
},
Expand All @@ -846,38 +844,11 @@ export const CssValueInput = ({
if (inputRef.current === null) {
return;
}
focusValue = inputRef.current.value;

focusTime = Date.now();
},
options
);
/*
inputRef.current.addEventListener(
"pointermove",
() => {
if (Date.now() - focusTime < 200) {
console.log("move");
inputRef.current?.select();
requestAnimationFrame(() => {
inputRef.current?.select();
});
}
},
options
);
inputRef.current.addEventListener(
"pointerup",
() => {
if (Date.now() - focusTime < 200) {
inputRef.current?.select();
requestAnimationFrame(() => {
inputRef.current?.select();
});
}
},
options
);
*/

return () => {
abortController.abort();
Expand Down Expand Up @@ -930,7 +901,6 @@ export const CssValueInput = ({
// We are setting the value on focus because we might have removed the var() from the value,
// but once focused, we need to show the full value
event.target.value = itemToString(value);
// event.target.select();
}
}}
autoFocus={autoFocus}
Expand Down
Loading

0 comments on commit 0e8a0e5

Please sign in to comment.