@mathscan/math-exercise-engine 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14239,6 +14239,29 @@ function useRotate(options) {
14239
14239
  const [rotation, setRotation] = React.useState(initialRotation);
14240
14240
  return { rotation, setRotation };
14241
14241
  }
14242
+ const REPEAT_DELAY_MS = 5e3;
14243
+ function useJiggle(isDragging) {
14244
+ const [jiggling, setJiggling] = React.useState(true);
14245
+ const [discovered, setDiscovered] = React.useState(false);
14246
+ const timerRef = React.useRef(null);
14247
+ React.useEffect(() => {
14248
+ if (isDragging && !discovered) {
14249
+ setDiscovered(true);
14250
+ if (timerRef.current) clearTimeout(timerRef.current);
14251
+ setJiggling(false);
14252
+ }
14253
+ }, [isDragging, discovered]);
14254
+ React.useEffect(() => () => {
14255
+ if (timerRef.current) clearTimeout(timerRef.current);
14256
+ }, []);
14257
+ const onAnimationEnd = React.useCallback(() => {
14258
+ setJiggling(false);
14259
+ if (!discovered) {
14260
+ timerRef.current = setTimeout(() => setJiggling(true), REPEAT_DELAY_MS);
14261
+ }
14262
+ }, [discovered]);
14263
+ return { jiggling, onAnimationEnd };
14264
+ }
14242
14265
  const VW$2 = 320;
14243
14266
  const VH$2 = 44;
14244
14267
  const RULER_ASPECT_RATIO = VH$2 / VW$2;
@@ -14628,6 +14651,7 @@ const DraggableTool = ({
14628
14651
  const [isFlipped, setIsFlipped] = React.useState(false);
14629
14652
  const drag = useDrag({ initialPosition });
14630
14653
  const rotate = useRotate({ initialRotation });
14654
+ const { jiggling, onAnimationEnd } = useJiggle(drag.isDragging);
14631
14655
  const dragRef = React.useRef(drag);
14632
14656
  const rotateRef = React.useRef(rotate);
14633
14657
  dragRef.current = drag;
@@ -14760,7 +14784,15 @@ const DraggableTool = ({
14760
14784
  onMouseMove: handleMouseMove,
14761
14785
  onMouseLeave: handleMouseLeave,
14762
14786
  children: [
14763
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { pointerEvents: "none", display: "block" }, children: /* @__PURE__ */ jsxRuntime.jsx(ToolContent, { type, width, imageSrc, flipped: isFlipped }) }),
14787
+ /* @__PURE__ */ jsxRuntime.jsx(
14788
+ "div",
14789
+ {
14790
+ className: jiggling ? "tool-content-jiggle" : void 0,
14791
+ onAnimationEnd,
14792
+ style: { pointerEvents: "none", display: "block" },
14793
+ children: /* @__PURE__ */ jsxRuntime.jsx(ToolContent, { type, width, imageSrc, flipped: isFlipped })
14794
+ }
14795
+ ),
14764
14796
  type === "set-square" && /* @__PURE__ */ jsxRuntime.jsx(
14765
14797
  "button",
14766
14798
  {