fui-fancyui
Version:
FancyUI Libary
49 lines (48 loc) • 1.71 kB
JavaScript
"use client";
import { jsx as v } from "react/jsx-runtime";
import { forwardRef as S, useState as E, useRef as Y, useId as D, useEffect as L } from "react";
import { styled as T } from "styled-components";
import w from "../SwipeUpDash/SwipeUpDash.js";
const R = S((s, f) => {
const { handleScaling: u, onClick: o } = s, [c, i] = E(!1), d = Y(0), a = D(), m = (e) => {
e === a && (i(!0), d.current = Date.now());
}, g = (e) => {
const t = e.target;
m(t.id);
}, p = (e) => {
const t = e.target;
m(t.id);
}, h = (e) => {
if (!c) return;
const n = e.clientY;
u("move", n);
}, l = (e) => {
if (!c) return;
const n = e.touches[0].clientY;
u("move", n);
}, r = (e) => {
if (!c) return;
i(!1), Date.now() - d.current < 150 && (o == null || o());
const n = y(e) ? e.changedTouches[0].clientY : e.clientY;
u("end", n);
};
return L(() => {
const e = { passive: !1 };
return document.addEventListener("mousemove", h, e), document.addEventListener("mouseup", r, e), document.addEventListener("touchmove", l, e), document.addEventListener("touchend", r, e), () => {
document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", r), document.removeEventListener("touchmove", l), document.removeEventListener("touchend", r);
};
}, [c]), /* @__PURE__ */ v(x, { id: a, ref: f, onTouchStart: p, onMouseDown: g, children: /* @__PURE__ */ v(w, { onClick: o }) });
}), x = T.div`
position: sticky;
height: 30px;
top: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
cursor: ns-resize;
z-index: 100;
`, y = (s) => "changedTouches" in s;
export {
R as default
};