Files
SnowLuma/.pnpm-store/v11/files/86/a43a87f782665bcc8a2b0f6115c3b07c489a07568294b4dd7e0fa385326238f689b606eaefd80cf3646a8277f4eaa91ccbf87a234b2dec8c18e6af282dd840
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

37 lines
1.3 KiB
Plaintext

import { Feature, press, frame } from 'motion-dom';
import { extractEventInfo } from '../events/event-info.mjs';
function handlePressEvent(node, event, lifecycle) {
const { props } = node;
if (node.current instanceof HTMLButtonElement && node.current.disabled) {
return;
}
if (node.animationState && props.whileTap) {
node.animationState.setActive("whileTap", lifecycle === "Start");
}
const eventName = ("onTap" + (lifecycle === "End" ? "" : lifecycle));
const callback = props[eventName];
if (callback) {
frame.postRender(() => callback(event, extractEventInfo(event)));
}
}
class PressGesture extends Feature {
mount() {
const { current } = this.node;
if (!current)
return;
const { globalTapTarget, propagate } = this.node.props;
this.unmount = press(current, (_element, startEvent) => {
handlePressEvent(this.node, startEvent, "Start");
return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
}, {
useGlobalTarget: globalTapTarget,
stopPropagation: propagate?.tap === false,
});
}
unmount() { }
}
export { PressGesture };
//# sourceMappingURL=press.mjs.map