@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.mjs CHANGED
@@ -14237,6 +14237,29 @@ function useRotate(options) {
14237
14237
  const [rotation, setRotation] = useState(initialRotation);
14238
14238
  return { rotation, setRotation };
14239
14239
  }
14240
+ const REPEAT_DELAY_MS = 5e3;
14241
+ function useJiggle(isDragging) {
14242
+ const [jiggling, setJiggling] = useState(true);
14243
+ const [discovered, setDiscovered] = useState(false);
14244
+ const timerRef = useRef(null);
14245
+ useEffect(() => {
14246
+ if (isDragging && !discovered) {
14247
+ setDiscovered(true);
14248
+ if (timerRef.current) clearTimeout(timerRef.current);
14249
+ setJiggling(false);
14250
+ }
14251
+ }, [isDragging, discovered]);
14252
+ useEffect(() => () => {
14253
+ if (timerRef.current) clearTimeout(timerRef.current);
14254
+ }, []);
14255
+ const onAnimationEnd = useCallback(() => {
14256
+ setJiggling(false);
14257
+ if (!discovered) {
14258
+ timerRef.current = setTimeout(() => setJiggling(true), REPEAT_DELAY_MS);
14259
+ }
14260
+ }, [discovered]);
14261
+ return { jiggling, onAnimationEnd };
14262
+ }
14240
14263
  const VW$2 = 320;
14241
14264
  const VH$2 = 44;
14242
14265
  const RULER_ASPECT_RATIO = VH$2 / VW$2;
@@ -14626,6 +14649,7 @@ const DraggableTool = ({
14626
14649
  const [isFlipped, setIsFlipped] = useState(false);
14627
14650
  const drag = useDrag({ initialPosition });
14628
14651
  const rotate = useRotate({ initialRotation });
14652
+ const { jiggling, onAnimationEnd } = useJiggle(drag.isDragging);
14629
14653
  const dragRef = useRef(drag);
14630
14654
  const rotateRef = useRef(rotate);
14631
14655
  dragRef.current = drag;
@@ -14758,7 +14782,15 @@ const DraggableTool = ({
14758
14782
  onMouseMove: handleMouseMove,
14759
14783
  onMouseLeave: handleMouseLeave,
14760
14784
  children: [
14761
- /* @__PURE__ */ jsx("div", { style: { pointerEvents: "none", display: "block" }, children: /* @__PURE__ */ jsx(ToolContent, { type, width, imageSrc, flipped: isFlipped }) }),
14785
+ /* @__PURE__ */ jsx(
14786
+ "div",
14787
+ {
14788
+ className: jiggling ? "tool-content-jiggle" : void 0,
14789
+ onAnimationEnd,
14790
+ style: { pointerEvents: "none", display: "block" },
14791
+ children: /* @__PURE__ */ jsx(ToolContent, { type, width, imageSrc, flipped: isFlipped })
14792
+ }
14793
+ ),
14762
14794
  type === "set-square" && /* @__PURE__ */ jsx(
14763
14795
  "button",
14764
14796
  {