fab keep at the last position

This commit is contained in:
Gabe Yuan
2023-08-16 22:38:58 +08:00
parent 7de712b2b0
commit 7b6391a673
5 changed files with 31 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import { useCallback, useEffect, useMemo, useState } from "react";
import { limitNumber } from "../../libs/utils";
import { isMobile } from "../../libs/mobile";
import { setFab } from "../../libs";
const getEdgePosition = (
{ x: left, y: top, edge },
@@ -88,7 +89,7 @@ export default function Draggable({
setEdgeTimer(
setTimeout(() => {
setPosition((pre) => getHidePosition(pre, w, h, width, height));
}, 2000)
}, 1500)
);
}, []);
@@ -149,6 +150,15 @@ export default function Draggable({
goEdge(windowSize.w, windowSize.h, width, height);
}, [snapEdge, goEdge, windowSize.w, windowSize.h, width, height]);
useEffect(() => {
if (position.hide) {
setFab({
x: position.x,
y: position.y,
});
}
}, [position]);
const opacity = useMemo(() => {
if (snapEdge) {
return position.hide ? 0.1 : 1;