fix: limit selection btn in window & click to hide
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
import { isMobile } from "../../libs/mobile";
|
import { isMobile } from "../../libs/mobile";
|
||||||
|
import { limitNumber } from "../../libs/utils";
|
||||||
|
|
||||||
export default function TranBtn({ onClick, position, tranboxSetting }) {
|
export default function TranBtn({ onClick, position, tranboxSetting }) {
|
||||||
const left = position.x + tranboxSetting.btnOffsetX;
|
const left = limitNumber(
|
||||||
const top = position.y + tranboxSetting.btnOffsetY;
|
position.x + tranboxSetting.btnOffsetX,
|
||||||
|
0,
|
||||||
|
window.innerWidth - 32
|
||||||
|
);
|
||||||
|
const top = limitNumber(
|
||||||
|
position.y + tranboxSetting.btnOffsetY,
|
||||||
|
0,
|
||||||
|
window.innerHeight - 32
|
||||||
|
);
|
||||||
|
|
||||||
const touchProps = isMobile
|
const touchProps = isMobile
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default function Slection({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function handleMouseup(e) {
|
async function handleMouseup(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
await sleep(10);
|
await sleep(100);
|
||||||
|
|
||||||
const selectedText = window.getSelection()?.toString()?.trim() || "";
|
const selectedText = window.getSelection()?.toString()?.trim() || "";
|
||||||
setSelText(selectedText);
|
setSelText(selectedText);
|
||||||
|
|||||||
Reference in New Issue
Block a user