@hh.ru/magritte-ui-media-viewer 1.3.11 → 1.3.13

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.
Files changed (46) hide show
  1. package/index.css +83 -83
  2. package/index.js +2 -2
  3. package/internal/Counter.js +2 -2
  4. package/internal/GalleryItemBody.js +14 -5
  5. package/internal/GalleryItemBody.js.map +1 -1
  6. package/internal/PreviewItem.js +2 -2
  7. package/internal/PreviewItemBody.js +2 -2
  8. package/internal/PreviewZoomControl.js +8 -5
  9. package/internal/PreviewZoomControl.js.map +1 -1
  10. package/internal/animations.d.ts +1 -1
  11. package/internal/animations.js +5 -5
  12. package/internal/animations.js.map +1 -1
  13. package/internal/context.js +1 -1
  14. package/internal/hooks/useAutoHideTools.js +3 -3
  15. package/internal/hooks/useAutoHideTools.js.map +1 -1
  16. package/internal/hooks/useDoubleTapScale.js +10 -4
  17. package/internal/hooks/useDoubleTapScale.js.map +1 -1
  18. package/internal/hooks/useGalleryItemController.js +2 -2
  19. package/internal/hooks/useGalleryItemController.js.map +1 -1
  20. package/internal/hooks/usePan.js +1 -1
  21. package/internal/hooks/usePinchToZoom.js +1 -1
  22. package/internal/hooks/useSwipe.js +2 -2
  23. package/internal/hooks/useSwipe.js.map +1 -1
  24. package/internal/hooks/useSwipeToClose.js +4 -4
  25. package/internal/hooks/useSwipeToClose.js.map +1 -1
  26. package/internal/hooks/useTapToToggleTools.js +2 -2
  27. package/internal/hooks/useTapToToggleTools.js.map +1 -1
  28. package/internal/hooks/useVirtualization.js +1 -1
  29. package/internal/hooks/useWheelToZoom.js +1 -1
  30. package/internal/utils.js +7 -4
  31. package/internal/utils.js.map +1 -1
  32. package/media-viewer-CFODj3fP.js +5 -0
  33. package/media-viewer-CFODj3fP.js.map +1 -0
  34. package/package.json +9 -9
  35. package/public/Footer.js +1 -1
  36. package/public/Gallery.js +2 -2
  37. package/public/GalleryItem.js +2 -2
  38. package/public/Header.js +1 -1
  39. package/public/MediaViewer.js +4 -4
  40. package/public/MediaViewer.js.map +1 -1
  41. package/public/Preview.js +16 -7
  42. package/public/Preview.js.map +1 -1
  43. package/public/Toolbar.js +2 -2
  44. package/public/Tools.js +1 -1
  45. package/media-viewer-Cc0v73D3.js +0 -5
  46. package/media-viewer-Cc0v73D3.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewZoomControl.js","sources":["src/internal/PreviewZoomControl.tsx"],"sourcesContent":["import { type FC, useState, useRef, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { MagnifierMinusOutlinedSize24, MagnifierPlusOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue, useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport {\n findNextValue,\n getDimensionsAfterRotation,\n clampOffset,\n useInitOnce,\n} from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\nconst getCurrentControllerLimits = (globalContext: MediaViewerContextValue) => {\n const controller = globalContext.currentSlideController.get();\n if (!controller) {\n return null;\n }\n const rotation = controller.rotation.get();\n const zoomStops = controller.zoomStops.get()[rotation % 2];\n return {\n min: zoomStops?.[0] ?? Number.NEGATIVE_INFINITY,\n max: zoomStops?.[zoomStops.length - 1] ?? Number.POSITIVE_INFINITY,\n };\n};\n\nexport const PreviewZoomControl: FC = () => {\n const globalContext = useMediaViewerContext();\n const [zoom, setZoom] = useState<number | null>(() => {\n const zoom = globalContext.currentSlideController.get()?.scale.get() || null;\n return zoom ? Math.round(zoom * 100) : null;\n });\n const updateZoom = useInitOnce(() => (newZoom: number | null) => {\n setZoom(newZoom ? Math.round(newZoom * 100) : null);\n });\n\n const [zoomLimits, setZoomLimits] = useState<{ min: number; max: number } | null>(() =>\n getCurrentControllerLimits(globalContext)\n );\n const prevControllerUnsubRef = useRef<VoidFunction[]>([]);\n const zoomInTrl = useTranslation('MediaViewer', 'zoomIn');\n const zoomOutTrl = useTranslation('MediaViewer', 'zoomOut');\n\n const applyNextZoom = (direction: 'in' | 'out') => {\n const controller = globalContext.currentSlideController.get();\n const contentSize = controller?.contentSize.get();\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n const rotation = controller?.rotation.get() ?? 0;\n if (!controller || !contentSize || !viewPortDimensions) {\n return;\n }\n const nextZoom = findNextValue(\n controller.zoomStops.get()[rotation % 2],\n controller.scale.get() ?? 1,\n direction === 'in'\n );\n\n controller.scale.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n\n const sizeAfterRotation = getDimensionsAfterRotation(contentSize, rotation);\n const clampedOffsetX = clampOffset(\n controller.offsetX.get(),\n sizeAfterRotation.width * nextZoom,\n viewPortDimensions.width\n );\n const clampedOffsetY = clampOffset(\n controller.offsetY.get(),\n sizeAfterRotation.height * nextZoom,\n viewPortDimensions.height\n );\n\n animate(controller.scale, nextZoom, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });\n animate(controller.offsetX, clampedOffsetX, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetY, clampedOffsetY, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n };\n\n useEffect(() => {\n const subs = [\n globalContext.currentSlideController.on('change', (controller) => {\n if (!controller) {\n return;\n }\n const scale = controller.scale.get() || null;\n updateZoom(scale);\n // слушаем всегда только один контроллер, от предыдущего надо отписаться\n prevControllerUnsubRef.current.forEach((unsub) => unsub());\n prevControllerUnsubRef.current = [\n controller.scale.on('change', updateZoom),\n controller.zoomStops.on('change', () => setZoomLimits(getCurrentControllerLimits(globalContext))),\n ];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }),\n () => prevControllerUnsubRef.current.forEach((unsub) => unsub()),\n ];\n\n const currentController = globalContext.currentSlideController.get();\n if (currentController) {\n prevControllerUnsubRef.current = [\n currentController.scale.on('change', updateZoom),\n currentController.zoomStops.on('change', () =>\n setZoomLimits(getCurrentControllerLimits(globalContext))\n ),\n ];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }\n return () => subs.forEach((unsub) => unsub?.());\n }, [globalContext, updateZoom]);\n\n return (\n <div className={styles.previewZoomControl}>\n <MagnifierMinusOutlinedSize24\n initialColor=\"constant\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom <= Math.round(zoomLimits?.min * 100))}\n onClick={() => {\n applyNextZoom('out');\n }}\n borderRadius=\"halfHeight\"\n aria-label={zoomOutTrl}\n />\n <Text style=\"constant\" typography=\"label-2-regular\">\n {`${zoom ?? 100}%`}\n </Text>\n <MagnifierPlusOutlinedSize24\n initialColor=\"constant\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom >= Math.round(zoomLimits?.max * 100))}\n onClick={() => {\n applyNextZoom('in');\n }}\n borderRadius=\"halfHeight\"\n aria-label={zoomInTrl}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,0BAA0B,GAAG,CAAC,aAAsC,KAAI;IAC1E,MAAM,UAAU,GAAG,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC;IAC9D,IAAI,CAAC,UAAU,EAAE;AACb,QAAA,OAAO,IAAI,CAAC;KACf;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;AAC3C,IAAA,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IAC3D,OAAO;QACH,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,iBAAiB;AAC/C,QA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A,EAAA,CAAA,EACR;AACN;;;;"}
1
+ {"version":3,"file":"PreviewZoomControl.js","sources":["src/internal/PreviewZoomControl.tsx"],"sourcesContent":["import { type FC, useState, useRef, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { MagnifierMinusOutlinedSize24, MagnifierPlusOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue, useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport {\n findNextValue,\n getDimensionsAfterRotation,\n clampOffset,\n useInitOnce,\n} from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from '../public/media-viewer.less';\n\nconst getCurrentControllerLimits = (globalContext: MediaViewerContextValue) => {\n const controller = globalContext.currentSlideController.get();\n if (!controller) {\n return null;\n }\n const rotation = controller.rotation.get();\n const zoomStops = controller.zoomStops.get()[rotation % 2];\n return {\n min: zoomStops?.[0] ?? Number.NEGATIVE_INFINITY,\n max: zoomStops?.[zoomStops.length - 1] ?? Number.POSITIVE_INFINITY,\n };\n};\n\nexport const PreviewZoomControl: FC = () => {\n const globalContext = useMediaViewerContext();\n const [zoom, setZoom] = useState<number | null>(() => {\n const zoom = globalContext.currentSlideController.get()?.scale.get() || null;\n return zoom ? Math.round(zoom * 100) : null;\n });\n const updateZoom = useInitOnce(() => (newZoom: number | null) => {\n setZoom(newZoom ? Math.round(newZoom * 100) : null);\n });\n\n const [zoomLimits, setZoomLimits] = useState<{ min: number; max: number } | null>(() =>\n getCurrentControllerLimits(globalContext)\n );\n const prevControllerUnsubRef = useRef<VoidFunction[]>([]);\n const zoomInTrl = useTranslation('MediaViewer', 'zoomIn');\n const zoomOutTrl = useTranslation('MediaViewer', 'zoomOut');\n\n const applyNextZoom = (direction: 'in' | 'out') => {\n const controller = globalContext.currentSlideController.get();\n const contentSize = controller?.contentSize.get();\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n const rotation = controller?.rotation.get() ?? 0;\n if (!controller || !contentSize || !viewPortDimensions) {\n return;\n }\n const nextZoom = findNextValue(\n controller.zoomStops.get()[rotation % 2],\n controller.scale.get() ?? 1,\n direction === 'in'\n );\n\n controller.scale.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n\n const sizeAfterRotation = getDimensionsAfterRotation(contentSize, rotation);\n const clampedOffsetX = clampOffset(\n controller.offsetX.get(),\n sizeAfterRotation.width * nextZoom,\n viewPortDimensions.width\n );\n const clampedOffsetY = clampOffset(\n controller.offsetY.get(),\n sizeAfterRotation.height * nextZoom,\n viewPortDimensions.height\n );\n\n animate(controller.scale, nextZoom, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetX, clampedOffsetX, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetY, clampedOffsetY, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n });\n };\n\n useEffect(() => {\n const subs = [\n globalContext.currentSlideController.on('change', (controller) => {\n if (!controller) {\n return;\n }\n const scale = controller.scale.get() || null;\n updateZoom(scale);\n // слушаем всегда только один контроллер, от предыдущего надо отписаться\n prevControllerUnsubRef.current.forEach((unsub) => unsub());\n prevControllerUnsubRef.current = [\n controller.scale.on('change', updateZoom),\n controller.zoomStops.on('change', () => setZoomLimits(getCurrentControllerLimits(globalContext))),\n ];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }),\n () => prevControllerUnsubRef.current.forEach((unsub) => unsub()),\n ];\n\n const currentController = globalContext.currentSlideController.get();\n if (currentController) {\n prevControllerUnsubRef.current = [\n currentController.scale.on('change', updateZoom),\n currentController.zoomStops.on('change', () =>\n setZoomLimits(getCurrentControllerLimits(globalContext))\n ),\n ];\n setZoomLimits(getCurrentControllerLimits(globalContext));\n }\n return () => subs.forEach((unsub) => unsub?.());\n }, [globalContext, updateZoom]);\n\n return (\n <div className={styles.previewZoomControl}>\n <MagnifierMinusOutlinedSize24\n initialColor=\"constant\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom <= Math.round(zoomLimits?.min * 100))}\n onClick={() => {\n applyNextZoom('out');\n }}\n borderRadius=\"halfHeight\"\n aria-label={zoomOutTrl}\n />\n <Text style=\"constant\" typography=\"label-2-regular\">\n {`${zoom ?? 100}%`}\n </Text>\n <MagnifierPlusOutlinedSize24\n initialColor=\"constant\"\n padding={8}\n disabled={zoom !== null && (zoomLimits === null || zoom >= Math.round(zoomLimits?.max * 100))}\n onClick={() => {\n applyNextZoom('in');\n }}\n borderRadius=\"halfHeight\"\n aria-label={zoomInTrl}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,0BAA0B,GAAG,CAAC,aAAsC,KAAI;IAC1E,MAAM,UAAU,GAAG,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC;IAC9D,IAAI,CAAC,UAAU,EAAE;AACb,QAAA,OAAO,IAAI,CAAC;KACf;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;AAC3C,IAAA,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IAC3D,OAAO;QACH,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,iBAAiB;AAC/C,QAAA,GAAG,EAAE,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,iBAAiB;KACrE,CAAC;AACN,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAO,MAAK;AACvC,IAAA,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E_BASE: readonly [0.4, 0.24, 0, 1];
1
+ export declare const EASE_BASE: readonly [number, number, number, number];
@@ -1,11 +1,11 @@
1
1
  import './../index.css';
2
- import { tokenSemanticAnimationEaseBaseX1, tokenSemanticAnimationEaseBaseY1, tokenSemanticAnimationEaseBaseX2, tokenSemanticAnimationEaseBaseY2 } from '@hh.ru/magritte-design-tokens/types';
2
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
3
3
 
4
4
  const EASE_BASE = [
5
- tokenSemanticAnimationEaseBaseX1,
6
- tokenSemanticAnimationEaseBaseY1,
7
- tokenSemanticAnimationEaseBaseX2,
8
- tokenSemanticAnimationEaseBaseY2,
5
+ CoreTokens['magritte-semantic-animation-ease-base'].x1,
6
+ CoreTokens['magritte-semantic-animation-ease-base'].y1,
7
+ CoreTokens['magritte-semantic-animation-ease-base'].x2,
8
+ CoreTokens['magritte-semantic-animation-ease-base'].y2,
9
9
  ];
10
10
 
11
11
  export { EASE_BASE };
@@ -1 +1 @@
1
- {"version":3,"file":"animations.js","sources":["src/internal/animations.ts"],"sourcesContent":["import {\n tokenSemanticAnimationEaseBaseX1,\n tokenSemanticAnimationEaseBaseX2,\n tokenSemanticAnimationEaseBaseY1,\n tokenSemanticAnimationEaseBaseY2,\n} from '@hh.ru/magritte-design-tokens/types';\n\nexport const EASE_BASE = [\n tokenSemanticAnimationEaseBaseX1,\n tokenSemanticAnimationEaseBaseY1,\n tokenSemanticAnimationEaseBaseX2,\n tokenSemanticAnimationEaseBaseY2,\n] as const;\n"],"names":[],"mappings":";;AAOa,MAAA,SAAS,GAAG;IACrB,gCAAgC;IAChC,gCAAgC;IAChC,gCAAgC;IAChC,gCAAgC;;;;;"}
1
+ {"version":3,"file":"animations.js","sources":["src/internal/animations.ts"],"sourcesContent":["import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\n\nexport const EASE_BASE = [\n CoreTokens['magritte-semantic-animation-ease-base'].x1,\n CoreTokens['magritte-semantic-animation-ease-base'].y1,\n CoreTokens['magritte-semantic-animation-ease-base'].x2,\n CoreTokens['magritte-semantic-animation-ease-base'].y2,\n] as const;\n"],"names":[],"mappings":";;AAEa,MAAA,SAAS,GAAG;AACrB,IAAA,UAAU,CAAC,uCAAuC,CAAC,CAAC,EAAE;AACtD,IAAA,UAAU,CAAC,uCAAuC,CAAC,CAAC,EAAE;AACtD,IAAA,UAAU,CAAC,uCAAuC,CAAC,CAAC,EAAE;AACtD,IAAA,UAAU,CAAC,uCAAuC,CAAC,CAAC,EAAE;;;;;"}
@@ -3,7 +3,7 @@ import { createContext, useContext, useState, useCallback } from 'react';
3
3
  import { motionValue, useMotionValueEvent } from 'motion/react';
4
4
  import { ImagesLoader } from './ImagesLoader.js';
5
5
  import { clamp } from './utils.js';
6
- import '@hh.ru/magritte-design-tokens/types';
6
+ import '@hh.ru/magritte-design-tokens/core-tokens';
7
7
  import './animations.js';
8
8
 
9
9
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
@@ -1,7 +1,7 @@
1
1
  import './../../index.css';
2
2
  import { useRef, useCallback, useEffect } from 'react';
3
3
  import { animate } from 'motion/react';
4
- import { tokenSemanticAnimationTimeLDuration } from '@hh.ru/magritte-design-tokens/types';
4
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
5
5
  import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
6
6
  import { EASE_BASE } from '../animations.js';
7
7
 
@@ -10,7 +10,7 @@ const useAutoHideTools = (context) => {
10
10
  const hideToolTimerRef = useRef(null);
11
11
  const { isMobile } = useBreakpoint();
12
12
  const hideTools = useCallback(() => animate(context.hideToolsProgress, 1, {
13
- duration: tokenSemanticAnimationTimeLDuration / 1000,
13
+ duration: CoreTokens['magritte-semantic-animation-time-l'].duration / 1000,
14
14
  ease: EASE_BASE,
15
15
  }), [context]);
16
16
  const showTools = useCallback(() => {
@@ -18,7 +18,7 @@ const useAutoHideTools = (context) => {
18
18
  return;
19
19
  }
20
20
  animate(context.hideToolsProgress, 0, {
21
- duration: tokenSemanticAnimationTimeLDuration / 1000,
21
+ duration: CoreTokens['magritte-semantic-animation-time-l'].duration / 1000,
22
22
  ease: EASE_BASE,
23
23
  });
24
24
  }, [context]);
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoHideTools.js","sources":["src/internal/hooks/useAutoHideTools.ts"],"sourcesContent":["import { useRef, useCallback, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport { tokenSemanticAnimationTimeLDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\n\nconst HIDE_TOOL_DELAY_MS = 6000;\n\ninterface UseAutoHideToolsResult {\n onMouseMove: VoidFunction;\n onClick: VoidFunction;\n}\n\nexport const useAutoHideTools = (context: MediaViewerContextValue): UseAutoHideToolsResult => {\n const hideToolTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const { isMobile } = useBreakpoint();\n\n const hideTools = useCallback(\n () =>\n animate(context.hideToolsProgress, 1, {\n duration: tokenSemanticAnimationTimeLDuration / 1000,\n ease: EASE_BASE,\n }),\n [context]\n );\n const showTools = useCallback(() => {\n if (context.hideToolsProgress.isAnimating() || context.hideToolsProgress.get() === 0) {\n return;\n }\n animate(context.hideToolsProgress, 0, {\n duration: tokenSemanticAnimationTimeLDuration / 1000,\n ease: EASE_BASE,\n });\n }, [context]);\n\n const resetTimer = useCallback(() => {\n if (hideToolTimerRef.current) {\n clearTimeout(hideToolTimerRef.current);\n }\n if (!isMobile) {\n hideToolTimerRef.current = setTimeout(hideTools, HIDE_TOOL_DELAY_MS);\n }\n }, [hideTools, isMobile]);\n\n const showOnAction = useCallback(() => {\n showTools();\n resetTimer();\n }, [showTools, resetTimer]);\n\n // Запускаем таймер при монтировании\n useEffect(() => {\n resetTimer();\n return () => {\n if (hideToolTimerRef.current) {\n clearTimeout(hideToolTimerRef.current);\n }\n };\n }, [resetTimer]);\n\n return { onMouseMove: showOnAction, onClick: showOnAction };\n};\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAOnB,MAAA,gBAAgB,GAAG,CAAC,OAAgC,KAA4B;AACzF,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;AAC5E,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;AAErC,IAAA,MAAM,SAAS,GAAG,WAAW,CACzB,MACI,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,EAAE;QAClC,QAAQ,EAAE,mCAAmC,GAAG,IAAI;AACpD,QAAA,IAAI,EAAE,SAAS;AAClB,KAAA,CAAC,EACN,CAAC,OAAO,CAAC,CACZ,CAAC;AACF,IAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAK;AAC/B,QAAA,IAAI,OAAO,CAAC,iBAAiB,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YAClF,OAAO;SACV;AACD,QAAA,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,EAAE;YAClC,QAAQ,EAAE,mCAAmC,GAAG,IAAI;AACpD,YAAA,IAAI,EAAE,SAAS;AAClB,SAAA,CAAC,CAAC;AACP,KAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAEd,IAAA,MAAM,UAAU,GAAG,WAAW,CAAC,MAAK;AAChC,QAAA,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC1B,YAAA,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;SAC1C;QACD,IAAI,CAAC,QAAQ,EAAE;YACX,gBAAgB,CAAC,OAAO,GAAG,UAAU,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;SACxE;AACL,KAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1B,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;AAClC,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,UAAU,EAAE,CAAC;AACjB,KAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;;IAG5B,SAAS,CAAC,MAAK;AACX,QAAA,UAAU,EAAE,CAAC;AACb,QAAA,OAAO,MAAK;AACR,YAAA,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC1B,gBAAA,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aAC1C;AACL,SAAC,CAAC;AACN,KAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAChE;;;;"}
1
+ {"version":3,"file":"useAutoHideTools.js","sources":["src/internal/hooks/useAutoHideTools.ts"],"sourcesContent":["import { useRef, useCallback, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\n\nconst HIDE_TOOL_DELAY_MS = 6000;\n\ninterface UseAutoHideToolsResult {\n onMouseMove: VoidFunction;\n onClick: VoidFunction;\n}\n\nexport const useAutoHideTools = (context: MediaViewerContextValue): UseAutoHideToolsResult => {\n const hideToolTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const { isMobile } = useBreakpoint();\n\n const hideTools = useCallback(\n () =>\n animate(context.hideToolsProgress, 1, {\n duration: CoreTokens['magritte-semantic-animation-time-l'].duration / 1000,\n ease: EASE_BASE,\n }),\n [context]\n );\n const showTools = useCallback(() => {\n if (context.hideToolsProgress.isAnimating() || context.hideToolsProgress.get() === 0) {\n return;\n }\n animate(context.hideToolsProgress, 0, {\n duration: CoreTokens['magritte-semantic-animation-time-l'].duration / 1000,\n ease: EASE_BASE,\n });\n }, [context]);\n\n const resetTimer = useCallback(() => {\n if (hideToolTimerRef.current) {\n clearTimeout(hideToolTimerRef.current);\n }\n if (!isMobile) {\n hideToolTimerRef.current = setTimeout(hideTools, HIDE_TOOL_DELAY_MS);\n }\n }, [hideTools, isMobile]);\n\n const showOnAction = useCallback(() => {\n showTools();\n resetTimer();\n }, [showTools, resetTimer]);\n\n // Запускаем таймер при монтировании\n useEffect(() => {\n resetTimer();\n return () => {\n if (hideToolTimerRef.current) {\n clearTimeout(hideToolTimerRef.current);\n }\n };\n }, [resetTimer]);\n\n return { onMouseMove: showOnAction, onClick: showOnAction };\n};\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAOnB,MAAA,gBAAgB,GAAG,CAAC,OAAgC,KAA4B;AACzF,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;AAC5E,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;AAErC,IAAA,MAAM,SAAS,GAAG,WAAW,CACzB,MACI,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,EAAE;QAClC,QAAQ,EAAE,UAAU,CAAC,oCAAoC,CAAC,CAAC,QAAQ,GAAG,IAAI;AAC1E,QAAA,IAAI,EAAE,SAAS;AAClB,KAAA,CAAC,EACN,CAAC,OAAO,CAAC,CACZ,CAAC;AACF,IAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAK;AAC/B,QAAA,IAAI,OAAO,CAAC,iBAAiB,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YAClF,OAAO;SACV;AACD,QAAA,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,EAAE;YAClC,QAAQ,EAAE,UAAU,CAAC,oCAAoC,CAAC,CAAC,QAAQ,GAAG,IAAI;AAC1E,YAAA,IAAI,EAAE,SAAS;AAClB,SAAA,CAAC,CAAC;AACP,KAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAEd,IAAA,MAAM,UAAU,GAAG,WAAW,CAAC,MAAK;AAChC,QAAA,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC1B,YAAA,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;SAC1C;QACD,IAAI,CAAC,QAAQ,EAAE;YACX,gBAAgB,CAAC,OAAO,GAAG,UAAU,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;SACxE;AACL,KAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1B,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;AAClC,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,UAAU,EAAE,CAAC;AACjB,KAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;;IAG5B,SAAS,CAAC,MAAK;AACX,QAAA,UAAU,EAAE,CAAC;AACb,QAAA,OAAO,MAAK;AACR,YAAA,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC1B,gBAAA,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aAC1C;AACL,SAAC,CAAC;AACN,KAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAChE;;;;"}
@@ -1,7 +1,7 @@
1
1
  import './../../index.css';
2
2
  import { useRef, useCallback } from 'react';
3
3
  import { animate } from 'motion/react';
4
- import { tokenSemanticAnimationTimeSDuration } from '@hh.ru/magritte-design-tokens/types';
4
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
5
5
  import { EASE_BASE } from '../animations.js';
6
6
  import { isClose } from '../utils.js';
7
7
 
@@ -34,11 +34,17 @@ const useDoubleTapScale = (controller) => {
34
34
  const closerToFill = Math.abs(currentScale - possibleTargets.fill) < Math.abs(currentScale - possibleTargets.fit);
35
35
  const next = (atFill || atFit) !== closerToFill ? 'fill' : 'fit';
36
36
  animate(controller.scale, possibleTargets[next], {
37
- duration: tokenSemanticAnimationTimeSDuration / 1000,
37
+ duration: CoreTokens['magritte-semantic-animation-time-s'].duration / 1000,
38
+ ease: EASE_BASE,
39
+ });
40
+ animate(controller.offsetX, 0, {
41
+ duration: CoreTokens['magritte-semantic-animation-time-s'].duration / 1000,
42
+ ease: EASE_BASE,
43
+ });
44
+ animate(controller.offsetY, 0, {
45
+ duration: CoreTokens['magritte-semantic-animation-time-s'].duration / 1000,
38
46
  ease: EASE_BASE,
39
47
  });
40
- animate(controller.offsetX, 0, { duration: tokenSemanticAnimationTimeSDuration / 1000, ease: EASE_BASE });
41
- animate(controller.offsetY, 0, { duration: tokenSemanticAnimationTimeSDuration / 1000, ease: EASE_BASE });
42
48
  }, [controller]);
43
49
  const handleTouchStart = useCallback(() => {
44
50
  pinchingRef.current = controller.pinching;
@@ -1 +1 @@
1
- {"version":3,"file":"useDoubleTapScale.js","sources":["src/internal/hooks/useDoubleTapScale.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { animate, type HTMLMotionProps } from 'motion/react';\n\nimport { tokenSemanticAnimationTimeSDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type GalleryItemController } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useGalleryItemController';\nimport { isClose } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nconst DOUBLE_TAP_DELAY = 300;\n\nexport const useDoubleTapScale = (controller: GalleryItemController): HTMLMotionProps<'div'> => {\n const lastTapRef = useRef(0);\n const pinchingRef = useRef(false);\n const lastDoubleTapRef = useRef(0);\n\n const handleDoubleTap = useCallback(() => {\n // Защита от повторного срабатывания\n const now = Date.now();\n if (now - lastDoubleTapRef.current < DOUBLE_TAP_DELAY) {\n return;\n }\n lastDoubleTapRef.current = now;\n\n if (controller.pinching) {\n return;\n }\n\n const currentScale = controller.scale.get();\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return;\n }\n\n controller.scale.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n\n const possibleTargets = fitFill[controller.rotation.get() % 2];\n const atFill = isClose(currentScale, possibleTargets.fill);\n const atFit = isClose(currentScale, possibleTargets.fit);\n const closerToFill =\n Math.abs(currentScale - possibleTargets.fill) < Math.abs(currentScale - possibleTargets.fit);\n\n const next = (atFill || atFit) !== closerToFill ? 'fill' : 'fit';\n animate(controller.scale, possibleTargets[next], {\n duration: tokenSemanticAnimationTimeSDuration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetX, 0, { duration: tokenSemanticAnimationTimeSDuration / 1000, ease: EASE_BASE });\n animate(controller.offsetY, 0, { duration: tokenSemanticAnimationTimeSDuration / 1000, ease: EASE_BASE });\n }, [controller]);\n\n const handleTouchStart = useCallback(() => {\n pinchingRef.current = controller.pinching;\n }, [controller]);\n\n const handleTouchEnd = useCallback(() => {\n if (controller.pinching || pinchingRef.current) {\n return;\n }\n const now = Date.now();\n\n if (now - lastTapRef.current < DOUBLE_TAP_DELAY) {\n handleDoubleTap();\n }\n lastTapRef.current = now;\n }, [handleDoubleTap, controller]);\n\n return { onTouchEnd: handleTouchEnd, onDoubleClick: handleDoubleTap, onTouchStart: handleTouchStart };\n};\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEhB,MAAA,iBAAiB,GAAG,CAAC,UAAiC,KAA4B;AAC3F,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAClC,IAAA,MAAM,gB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esContent":["import { useCallback, useRef } from 'react';\nimport { animate, type HTMLMotionProps } from 'motion/react';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type GalleryItemController } from '@hh.ru/magritte-ui-media-viewer/internal/hooks/useGalleryItemController';\nimport { isClose } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nconst DOUBLE_TAP_DELAY = 300;\n\nexport const useDoubleTapScale = (controller: GalleryItemController): HTMLMotionProps<'div'> => {\n const lastTapRef = useRef(0);\n const pinchingRef = useRef(false);\n const lastDoubleTapRef = useRef(0);\n\n const handleDoubleTap = useCallback(() => {\n // Защита от повторного срабатывания\n const now = Date.now();\n if (now - lastDoubleTapRef.current < DOUBLE_TAP_DELAY) {\n return;\n }\n lastDoubleTapRef.current = now;\n\n if (controller.pinching) {\n return;\n }\n\n const currentScale = controller.scale.get();\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return;\n }\n\n controller.scale.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n\n const possibleTargets = fitFill[controller.rotation.get() % 2];\n const atFill = isClose(currentScale, possibleTargets.fill);\n const atFit = isClose(currentScale, possibleTargets.fit);\n const closerToFill =\n Math.abs(currentScale - possibleTargets.fill) < Math.abs(currentScale - possibleTargets.fit);\n\n const next = (atFill || atFit) !== closerToFill ? 'fill' : 'fit';\n animate(controller.scale, possibleTargets[next], {\n duration: CoreTokens['magritte-semantic-animation-time-s'].duration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetX, 0, {\n duration: CoreTokens['magritte-semantic-animation-time-s'].duration / 1000,\n ease: EASE_BASE,\n });\n animate(controller.offsetY, 0, {\n duration: CoreTokens['magritte-semantic-animation-time-s'].duration / 1000,\n ease: EASE_BASE,\n });\n }, [controller]);\n\n const handleTouchStart = useCallback(() => {\n pinchingRef.current = controller.pinching;\n }, [controller]);\n\n const handleTouchEnd = useCallback(() => {\n if (controller.pinching || pinchingRef.current) {\n return;\n }\n const now = Date.now();\n\n if (now - lastTapRef.current < DOUBLE_TAP_DELAY) {\n handleDoubleTap();\n }\n lastTapRef.current = now;\n }, [handleDoubleTap, controller]);\n\n return { onTouchEnd: handleTouchEnd, onDoubleClick: handleDoubleTap, onTouchStart: handleTouchStart };\n};\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEhB,MAAA,iBAAiB,GAAG,CAAC,UAAiC,KAA4B;AAC3F,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAClC,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,MAAK;;AAErC,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,GAAG,GAAG,gBAAgB,CAAC,OAAO,GAAG,gBAAgB,EAAE;YACnD,OAAO;SACV;AACD,QAAA,gBAAgB,CAAC,OAAO,GAAG,GAAG,CAAC;AAE/B,QAAA,IAAI,UAAU,CAAC,QAAQ,EAAE;YACrB,OAAO;SACV;QAED,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;AAC/C,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;YAClB,OAAO;SACV;AAED,QAAA,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AACxB,QAAA,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AAC1B,QAAA,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AAE1B,QAAA,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAA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,IAAA,MAAM,cAAc,GAAG,WAAW,CAAC,MAAK;QACpC,IAAI,UAAU,CAAC,QAAQ,IAAI,WAAW,CAAC,OAAO,EAAE;YAC5C,OAAO;SACV;AACD,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,gBAAgB,EAAE;AAC7C,YAAA,eAAe,EAAE,CAAC;SACrB;AACD,QAAA,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AAC7B,KAAC,EAAE,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;AAElC,IAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC1G;;;;"}
@@ -1,7 +1,7 @@
1
1
  import './../../index.css';
2
2
  import { useEffect } from 'react';
3
3
  import { motionValue, animate } from 'motion/react';
4
- import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
4
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
5
5
  import { EASE_BASE } from '../animations.js';
6
6
  import { useInitOnce } from '../utils.js';
7
7
 
@@ -114,7 +114,7 @@ const useGalleryItemController = (globalContext, url, index, description) => {
114
114
  isFullyInvisible(controller, globalContext)
115
115
  ? controller.scale.set(targetScale)
116
116
  : animate(controller.scale, targetScale, {
117
- duration: tokenSemanticAnimationTimeMDuration / 1000,
117
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
118
118
  ease: EASE_BASE,
119
119
  });
120
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useGalleryItemController.js","sources":["src/internal/hooks/useGalleryItemController.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { type MotionValue, motionValue, animate } from 'motion/react';\n\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { useInitOnce } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Size } from '@hh.ru/magritte-ui-media-viewer/public/types';\n\nconst computeFitScale = (container: Size, content: Size): number => {\n return Math.min(container.width / content.width, container.height / content.height);\n};\n\n// fit и fill масштабы для горизонтальной и вертикальной ориентации\nexport type FitFillScales = [{ fit: number; fill: number }, { fit: number; fill: number }] | null;\n\nconst computeFitFill = (containerSize: Size | null, contentSize: Size | null): FitFillScales => {\n if (\n !containerSize ||\n !contentSize ||\n contentSize.width === 0 ||\n contentSize.height === 0 ||\n containerSize.width === 0 ||\n containerSize.height === 0\n ) {\n return null;\n }\n const contentRotatedSize = { width: contentSize.height, height: contentSize.width };\n return [\n {\n fit: computeFitScale(containerSize, contentSize),\n fill: Math.max(3, 1 / computeFitScale(contentSize, containerSize)),\n },\n {\n fit: computeFitScale(containerSize, contentRotatedSize),\n fill: Math.max(3, 1 / computeFitScale(contentRotatedSize, containerSize)),\n },\n ];\n};\n\nconst getCurrentScaleType = (\n controller: {\n scale: MotionValue<number>;\n rotation: MotionValue<number>;\n fitFillScales: MotionValue<FitFillScales>;\n },\n rot?: number\n): 'fit' | 'fill' | null => {\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return null;\n }\n\n const rotation = rot ?? controller.rotation.get();\n const fitFillForRotation = fitFill[rotation % 2];\n const currentScale = controller.scale.get();\n\n if (Math.abs(currentScale - fitFillForRotation.fit) < 0.01) {\n return 'fit';\n }\n if (Math.abs(currentScale - fitFillForRotation.fill) < 0.01) {\n return 'fill';\n }\n return null;\n};\n\nexport interface GalleryItemController {\n scale: MotionValue<number>;\n rotation: MotionValue<number>;\n offsetX: MotionValue<number>;\n offsetY: MotionValue<number>;\n contentSize: MotionValue<Size | null>;\n fitFillScales: MotionValue<FitFillScales>;\n index: MotionValue<number>;\n pinching: boolean;\n zoomStops: MotionValue<number[][]>;\n url: MotionValue<string | undefined>;\n description: MotionValue<string | undefined>;\n}\n\nexport const isFullyInvisible = (\n controller: GalleryItemController,\n globalContext: MediaViewerContextValue\n): boolean => {\n const currentIndex = globalContext.currentSlideIndex.get();\n const itemIndex = controller.index.get();\n return itemIndex + 1 <= currentIndex || itemIndex - 1 >= currentIndex;\n};\n\nconst ZOOM_STOPS = [1, 2, 4];\n\nexport const useGalleryItemController = (\n globalContext: MediaViewerContextValue,\n url: string,\n index: number,\n description?: string\n): [(size: Size | null) => void, GalleryItemController] => {\n const controller = useInitOnce(() => {\n const controller: GalleryItemController = {\n scale: motionValue(1),\n rotation: motionValue(0),\n offsetX: motionValue(0),\n offsetY: motionValue(0),\n contentSize: motionValue<Size | null>(null),\n fitFillScales: motionValue<FitFillScales>(null),\n index: motionValue<number>(index),\n pinching: false,\n zoomStops: motionValue<number[][]>([]),\n url: motionValue<string | undefined>(url),\n description: motionValue<string | undefined>(description),\n };\n\n return controller;\n });\n\n useEffect(() => {\n controller.url.set(url);\n controller.description.set(description);\n controller.index.set(index);\n }, [url, controller, description, index]);\n\n const setContentSize = useInitOnce(() => (size: Size | null) => {\n const currentSize = controller.contentSize.get();\n if (\n currentSize === null ||\n size === null ||\n currentSize.width !== size.width ||\n currentSize.height !== size.height\n ) {\n controller.contentSize.set(size);\n }\n });\n\n const resetTransforms = useInitOnce(() => (globalContext: MediaViewerContextValue) => {\n if (!isFullyInvisible(controller, globalContext)) {\n return;\n }\n controller.rotation.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n controller.scale.stop();\n controller.rotation.set(0);\n controller.offsetX.set(0);\n controller.offsetY.set(0);\n\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return;\n }\n\n const fit = fitFill[controller.rotation.get() % 2].fit;\n controller.scale.set(Math.min(fit, 1));\n });\n\n const updateScaleOnRotation = useInitOnce(() => (globalContext: MediaViewerContextValue) => {\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return;\n }\n\n const prevRotation = controller.rotation.get() + 1;\n const scaleType = getCurrentScaleType(controller, prevRotation);\n if (scaleType) {\n const targetScale = fitFill[controller.rotation.get() % 2][scaleType];\n controller.scale.stop();\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n isFullyInvisible(controller, globalContext)\n ? controller.scale.set(targetScale)\n : animate(controller.scale, targetScale, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n }\n });\n\n const attachController = useInitOnce(() => (globalContext: MediaViewerContextValue) => {\n if (Math.round(globalContext.currentSlideIndex.get()) === controller.index.get()) {\n globalContext.currentSlideController.set(controller);\n }\n });\n\n useEffect(() => {\n const updateFitFill = () => {\n const contentSize = controller.contentSize.get();\n const viewportDimensions = globalContext.viewPortDimensions.get();\n const prevFitFill = controller.fitFillScales.get();\n const scaleType = prevFitFill === null ? 'fit' : getCurrentScaleType(controller);\n controller.fitFillScales.set(computeFitFill(viewportDimensions, contentSize));\n const fitFill = controller.fitFillScales.get();\n if (scaleType && fitFill) {\n controller.scale.set(Math.min(fitFill[controller.rotation.get() % 2][scaleType], 1));\n }\n };\n\n const updateZoomStops = () => {\n const fitFill = controller.fitFillScales.get();\n if (!fitFill) {\n return;\n }\n const zoomStops: number[][] = [];\n for (const sizeOrientation of fitFill) {\n let stops = [...ZOOM_STOPS];\n stops.push(sizeOrientation.fit, sizeOrientation.fill);\n stops = [...new Set(stops.sort((a, b) => a - b))];\n zoomStops.push(stops);\n }\n\n controller.zoomStops.set(zoomStops);\n };\n\n const subscriptions = [\n // Обновление fit/fill при изменении размеров контента или вьюпорта\n controller.contentSize.on('change', () => {\n updateFitFill();\n updateZoomStops();\n }),\n globalContext.viewPortDimensions.on('change', () => {\n updateFitFill();\n updateZoomStops();\n }),\n\n // Сброс трансформации при смене слайда\n globalContext.currentSlideIndex.on('change', () => resetTransforms(globalContext)),\n controller.index.on('change', () => resetTransforms(globalContext)),\n\n // Обновление масштаба при изменении поворота\n controller.rotation.on('change', () => {\n updateScaleOnRotation(globalContext);\n updateZoomStops();\n }),\n\n // Установка контроллера активного слайда в глобальный контекст\n globalContext.currentSlideIndex.on('change', () => attachController(globalContext)),\n controller.index.on('change', () => attachController(globalContext)),\n ];\n\n attachController(globalContext);\n updateFitFill();\n updateZoomStops();\n\n return () => subscriptions.forEach((unsub) => unsub());\n }, [controller, globalContext, resetTransforms, updateScaleOnRotation, attachController]);\n\n return [setContentSize, controller] as const;\n};\n"],"names":[],"mappings":";;;;;;AASA,MAAM,eAAe,GAAG,CAAC,SAAe,EAAE,OAAa,KAAY;IAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACxF,CAAC,CAAC;AAKF,MAAM,cAAc,GAAG,CAAC,aAA0B,EAAE,WAAwB,KAAmB;AAC3F,IAAA,IACI,CAAC,aAAa;AACd,QAAA,CAAC,WAAW;QACZ,WAAW,CAAC,KAAK,KAAK,CAAC;QACvB,WAAW,CAAC,MAAM,KAAK,CAAC;QACxB,aAAa,CAAC,KAAK,KAAK,CAAC;AACzB,QAAA,aAAa,CAAC,MAAM,KAAK,CAAC,EAC5B;AACE,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC;IACpF,OAAO;AACH,QAAA;AACI,YAAA,GAAG,EAAE,eAAe,CAAC,aAAa,EAAE,WAAW,CAAC;AAChD,YAAA,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACrE,SAAA;AACD,QAAA;AACI,YAAA,GAAG,EAAE,eAAe,CAAC,aAAa,EAAE,kBAAkB,CAAC;AACvD,YAAA,IAAI,EA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AU,CAAC;AACjD;;;;"}
1
+ {"version":3,"file":"useGalleryItemController.js","sources":["src/internal/hooks/useGalleryItemController.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { type MotionValue, motionValue, animate } from 'motion/react';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { useInitOnce } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\nimport { Size } from '@hh.ru/magritte-ui-media-viewer/public/types';\n\nconst computeFitScale = (container: Size, content: Size): number => {\n return Math.min(container.width / content.width, container.height / content.height);\n};\n\n// fit и fill масштабы для горизонтальной и вертикальной ориентации\nexport type FitFillScales = [{ fit: number; fill: number }, { fit: number; fill: number }] | null;\n\nconst computeFitFill = (containerSize: Size | null, contentSize: Size | null): FitFillScales => {\n if (\n !containerSize ||\n !contentSize ||\n contentSize.width === 0 ||\n contentSize.height === 0 ||\n containerSize.width === 0 ||\n containerSize.height === 0\n ) {\n return null;\n }\n const contentRotatedSize = { width: contentSize.height, height: contentSize.width };\n return [\n {\n fit: computeFitScale(containerSize, contentSize),\n fill: Math.max(3, 1 / computeFitScale(contentSize, containerSize)),\n },\n {\n fit: computeFitScale(containerSize, contentRotatedSize),\n fill: Math.max(3, 1 / computeFitScale(contentRotatedSize, containerSize)),\n },\n ];\n};\n\nconst getCurrentScaleType = (\n controller: {\n scale: MotionValue<number>;\n rotation: MotionValue<number>;\n fitFillScales: MotionValue<FitFillScales>;\n },\n rot?: number\n): 'fit' | 'fill' | null => {\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return null;\n }\n\n const rotation = rot ?? controller.rotation.get();\n const fitFillForRotation = fitFill[rotation % 2];\n const currentScale = controller.scale.get();\n\n if (Math.abs(currentScale - fitFillForRotation.fit) < 0.01) {\n return 'fit';\n }\n if (Math.abs(currentScale - fitFillForRotation.fill) < 0.01) {\n return 'fill';\n }\n return null;\n};\n\nexport interface GalleryItemController {\n scale: MotionValue<number>;\n rotation: MotionValue<number>;\n offsetX: MotionValue<number>;\n offsetY: MotionValue<number>;\n contentSize: MotionValue<Size | null>;\n fitFillScales: MotionValue<FitFillScales>;\n index: MotionValue<number>;\n pinching: boolean;\n zoomStops: MotionValue<number[][]>;\n url: MotionValue<string | undefined>;\n description: MotionValue<string | undefined>;\n}\n\nexport const isFullyInvisible = (\n controller: GalleryItemController,\n globalContext: MediaViewerContextValue\n): boolean => {\n const currentIndex = globalContext.currentSlideIndex.get();\n const itemIndex = controller.index.get();\n return itemIndex + 1 <= currentIndex || itemIndex - 1 >= currentIndex;\n};\n\nconst ZOOM_STOPS = [1, 2, 4];\n\nexport const useGalleryItemController = (\n globalContext: MediaViewerContextValue,\n url: string,\n index: number,\n description?: string\n): [(size: Size | null) => void, GalleryItemController] => {\n const controller = useInitOnce(() => {\n const controller: GalleryItemController = {\n scale: motionValue(1),\n rotation: motionValue(0),\n offsetX: motionValue(0),\n offsetY: motionValue(0),\n contentSize: motionValue<Size | null>(null),\n fitFillScales: motionValue<FitFillScales>(null),\n index: motionValue<number>(index),\n pinching: false,\n zoomStops: motionValue<number[][]>([]),\n url: motionValue<string | undefined>(url),\n description: motionValue<string | undefined>(description),\n };\n\n return controller;\n });\n\n useEffect(() => {\n controller.url.set(url);\n controller.description.set(description);\n controller.index.set(index);\n }, [url, controller, description, index]);\n\n const setContentSize = useInitOnce(() => (size: Size | null) => {\n const currentSize = controller.contentSize.get();\n if (\n currentSize === null ||\n size === null ||\n currentSize.width !== size.width ||\n currentSize.height !== size.height\n ) {\n controller.contentSize.set(size);\n }\n });\n\n const resetTransforms = useInitOnce(() => (globalContext: MediaViewerContextValue) => {\n if (!isFullyInvisible(controller, globalContext)) {\n return;\n }\n controller.rotation.stop();\n controller.offsetX.stop();\n controller.offsetY.stop();\n controller.scale.stop();\n controller.rotation.set(0);\n controller.offsetX.set(0);\n controller.offsetY.set(0);\n\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return;\n }\n\n const fit = fitFill[controller.rotation.get() % 2].fit;\n controller.scale.set(Math.min(fit, 1));\n });\n\n const updateScaleOnRotation = useInitOnce(() => (globalContext: MediaViewerContextValue) => {\n const fitFill = controller.fitFillScales.get();\n if (fitFill === null) {\n return;\n }\n\n const prevRotation = controller.rotation.get() + 1;\n const scaleType = getCurrentScaleType(controller, prevRotation);\n if (scaleType) {\n const targetScale = fitFill[controller.rotation.get() % 2][scaleType];\n controller.scale.stop();\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n isFullyInvisible(controller, globalContext)\n ? controller.scale.set(targetScale)\n : animate(controller.scale, targetScale, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n });\n }\n });\n\n const attachController = useInitOnce(() => (globalContext: MediaViewerContextValue) => {\n if (Math.round(globalContext.currentSlideIndex.get()) === controller.index.get()) {\n globalContext.currentSlideController.set(controller);\n }\n });\n\n useEffect(() => {\n const updateFitFill = () => {\n const contentSize = controller.contentSize.get();\n const viewportDimensions = globalContext.viewPortDimensions.get();\n const prevFitFill = controller.fitFillScales.get();\n const scaleType = prevFitFill === null ? 'fit' : getCurrentScaleType(controller);\n controller.fitFillScales.set(computeFitFill(viewportDimensions, contentSize));\n const fitFill = controller.fitFillScales.get();\n if (scaleType && fitFill) {\n controller.scale.set(Math.min(fitFill[controller.rotation.get() % 2][scaleType], 1));\n }\n };\n\n const updateZoomStops = () => {\n const fitFill = controller.fitFillScales.get();\n if (!fitFill) {\n return;\n }\n const zoomStops: number[][] = [];\n for (const sizeOrientation of fitFill) {\n let stops = [...ZOOM_STOPS];\n stops.push(sizeOrientation.fit, sizeOrientation.fill);\n stops = [...new Set(stops.sort((a, b) => a - b))];\n zoomStops.push(stops);\n }\n\n controller.zoomStops.set(zoomStops);\n };\n\n const subscriptions = [\n // Обновление fit/fill при изменении размеров контента или вьюпорта\n controller.contentSize.on('change', () => {\n updateFitFill();\n updateZoomStops();\n }),\n globalContext.viewPortDimensions.on('change', () => {\n updateFitFill();\n updateZoomStops();\n }),\n\n // Сброс трансформации при смене слайда\n globalContext.currentSlideIndex.on('change', () => resetTransforms(globalContext)),\n controller.index.on('change', () => resetTransforms(globalContext)),\n\n // Обновление масштаба при изменении поворота\n controller.rotation.on('change', () => {\n updateScaleOnRotation(globalContext);\n updateZoomStops();\n }),\n\n // Установка контроллера активного слайда в глобальный контекст\n globalContext.currentSlideIndex.on('change', () => attachController(globalContext)),\n controller.index.on('change', () => attachController(globalContext)),\n ];\n\n attachController(globalContext);\n updateFitFill();\n updateZoomStops();\n\n return () => subscriptions.forEach((unsub) => unsub());\n }, [controller, globalContext, resetTransforms, updateScaleOnRotation, attachController]);\n\n return [setContentSize, controller] as const;\n};\n"],"names":[],"mappings":";;;;;;AASA,MAAM,eAAe,GAAG,CAAC,SAAe,EAAE,OAAa,KAAY;IAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACxF,CAAC,CAAC;AAKF,MAAM,cAAc,GAAG,CAAC,aAA0B,EAAE,WAAwB,KAAmB;AAC3F,IAAA,IACI,CAAC,aAAa;AACd,QAAA,CAAC,WAAW;QACZ,WAAW,CAAC,KAAK,KAAK,CAAC;QACvB,WAAW,CAAC,MAAM,KAAK,CAAC;QACxB,aAAa,CAAC,KAAK,KAAK,CAAC;AACzB,QAAA,aAAa,CAAC,MAAM,KAAK,CAAC,EAC5B;AACE,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC;IACpF,OAAO;AACH,QAAA;AACI,YAAA,GAAG,EAAE,eAAe,CAAC,aAAa,EAAE,W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QAAA,eAAe,EAAE,CAAC;AAElB,QAAA,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC,CAAC;AAC3D,KAAC,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE1F,IAAA,OAAO,CAAC,cAAc,EAAE,UAAU,CAAU,CAAC;AACjD;;;;"}
@@ -3,7 +3,7 @@ import { useRef } from 'react';
3
3
  import { useDrag } from '@use-gesture/react';
4
4
  import { isScaleBiggerThanFit, getDimensionsAfterRotation, clampOffset, lerp, animateOffsetClamp } from '../utils.js';
5
5
  import 'motion/react';
6
- import '@hh.ru/magritte-design-tokens/types';
6
+ import '@hh.ru/magritte-design-tokens/core-tokens';
7
7
  import '../animations.js';
8
8
 
9
9
  const usePan = (controller, dimensions) => {
@@ -3,7 +3,7 @@ import { useRef, useCallback } from 'react';
3
3
  import { usePinch } from '@use-gesture/react';
4
4
  import { calcOriginOffset, lerp, animateOffsetClamp } from '../utils.js';
5
5
  import 'motion/react';
6
- import '@hh.ru/magritte-design-tokens/types';
6
+ import '@hh.ru/magritte-design-tokens/core-tokens';
7
7
  import '../animations.js';
8
8
 
9
9
  // pinch to zoom хук, сохраняет позицию точки между пальцами при зуме неподвижной
@@ -1,7 +1,7 @@
1
1
  import './../../index.css';
2
2
  import { useDrag } from '@use-gesture/react';
3
3
  import { animate } from 'motion/react';
4
- import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
4
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
5
5
  import { EASE_BASE } from '../animations.js';
6
6
  import { useMediaViewerContext } from '../context.js';
7
7
  import { isScaleBiggerThanFit, clamp } from '../utils.js';
@@ -24,7 +24,7 @@ const useSwipe = () => {
24
24
  if (state.last) {
25
25
  const targetIndex = clamp(Math.round(globalContext.currentSlideIndex.get()), 0, globalContext.totalSlides.get() - 1);
26
26
  const delta = Math.abs(globalContext.currentSlideIndex.get() - targetIndex);
27
- const animationDuration = tokenSemanticAnimationTimeMDuration * delta;
27
+ const animationDuration = CoreTokens['magritte-semantic-animation-time-m'].duration * delta;
28
28
  animate(globalContext.currentSlideIndex, clamp(Math.round(globalContext.currentSlideIndex.get()), 0, globalContext.totalSlides.get() - 1), {
29
29
  duration: animationDuration / 1000,
30
30
  ease: EASE_BASE,
@@ -1 +1 @@
1
- {"version":3,"file":"useSwipe.js","sources":["src/internal/hooks/useSwipe.ts"],"sourcesContent":["import { useDrag } from '@use-gesture/react';\nimport { animate } from 'motion/react';\n\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { clamp, isScaleBiggerThanFit } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nexport const useSwipe = <T>(): ReturnType<typeof useDrag<T>> => {\n const globalContext = useMediaViewerContext();\n\n return useDrag<T>(\n (state) => {\n const controller = globalContext.currentSlideController.get();\n if (!controller || isScaleBiggerThanFit(controller) || controller.pinching) {\n state.cancel();\n return;\n }\n\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n if (!viewPortDimensions) {\n return;\n }\n\n globalContext.currentSlideIndex.set(\n clamp(\n globalContext.currentSlideIndex.get() - state.delta[0] / viewPortDimensions.width,\n 0,\n globalContext.totalSlides.get() - 1\n )\n );\n\n if (state.last) {\n const targetIndex = clamp(\n Math.round(globalContext.currentSlideIndex.get()),\n 0,\n globalContext.totalSlides.get() - 1\n );\n const delta = Math.abs(globalContext.currentSlideIndex.get() - targetIndex);\n const animationDuration = tokenSemanticAnimationTimeMDuration * delta;\n animate(\n globalContext.currentSlideIndex,\n clamp(Math.round(globalContext.currentSlideIndex.get()), 0, globalContext.totalSlides.get() - 1),\n {\n duration: animationDuration / 1000,\n ease: EASE_B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OAAO,CACH,aAAa,CAAC,iBAAiB,EAC/B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAChG;gBACI,QAAQ,EAAE,iBAAiB,GAAG,IAAI;AAClC,gBAAA,IAAI,EAAE,SAAS;AAClB,aAAA,CACJ,CAAC;SACL;AACL,KAAC,EACD;QACI,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AAClB,QAAA,IAAI,EAAE,GAAG;AACT,QAAA,oBAAoB,EAAE,CAAC;AAC1B,KAAA,CACJ,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"useSwipe.js","sources":["src/internal/hooks/useSwipe.ts"],"sourcesContent":["import { useDrag } from '@use-gesture/react';\nimport { animate } from 'motion/react';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { useMediaViewerContext } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { clamp, isScaleBiggerThanFit } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nexport const useSwipe = <T>(): ReturnType<typeof useDrag<T>> => {\n const globalContext = useMediaViewerContext();\n\n return useDrag<T>(\n (state) => {\n const controller = globalContext.currentSlideController.get();\n if (!controller || isScaleBiggerThanFit(controller) || controller.pinching) {\n state.cancel();\n return;\n }\n\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n if (!viewPortDimensions) {\n return;\n }\n\n globalContext.currentSlideIndex.set(\n clamp(\n globalContext.currentSlideIndex.get() - state.delta[0] / viewPortDimensions.width,\n 0,\n globalContext.totalSlides.get() - 1\n )\n );\n\n if (state.last) {\n const targetIndex = clamp(\n Math.round(globalContext.currentSlideIndex.get()),\n 0,\n globalContext.totalSlides.get() - 1\n );\n const delta = Math.abs(globalContext.currentSlideIndex.get() - targetIndex);\n const animationDuration = CoreTokens['magritte-semantic-animation-time-m'].duration * delta;\n animate(\n globalContext.currentSlideIndex,\n clamp(Math.round(globalContext.currentSlideIndex.get()), 0, globalContext.totalSlides.get() - 1),\n {\n duration: animationDuration / 1000,\n ease: EASE_BASE,\n }\n );\n }\n },\n {\n from: () => [0, 0],\n axis: 'x',\n keyboardDisplacement: 0,\n }\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAQO,MAAM,QAAQ,GAAG,MAAuC;AAC3D,IAAA,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;AAE9C,IAAA,OAAO,OAAO,CACV,CAAC,KAAK,KAAI;QACN,MAAM,UAAU,GAAG,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC;AAC9D,QAAA,IAAI,CAAC,UAAU,IAAI,oBAAoB,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE;YACxE,KAAK,CAAC,MAAM,EAAE,CAAC;YACf,OAAO;SACV;QAED,MAAM,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;QAClE,IAAI,CAAC,kBAAkB,EAAE;YACrB,OAAO;SACV;AAED,QAAA,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAC/B,KAAK,CACD,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,KAAK,EACjF,CAAC,EACD,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CACtC,CACJ,CAAC;AAEF,QAAA,IAAI,KAAK,CAAC,IAAI,EAAE;YACZ,MAAM,WAAW,GAAG,KAAK,CACrB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,EACjD,CAAC,EACD,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CACtC,CAAC;AACF,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,CAAC;YAC5E,MAAM,iBAAiB,GAAG,UAAU,CAAC,oCAAoC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;AAC5F,YAAA,OAAO,CACH,aAAa,CAAC,iBAAiB,EAC/B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAChG;gBACI,QAAQ,EAAE,iBAAiB,GAAG,IAAI;AAClC,gBAAA,IAAI,EAAE,SAAS;AAClB,aAAA,CACJ,CAAC;SACL;AACL,KAAC,EACD;QACI,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AAClB,QAAA,IAAI,EAAE,GAAG;AACT,QAAA,oBAAoB,EAAE,CAAC;AAC1B,KAAA,CACJ,CAAC;AACN;;;;"}
@@ -2,7 +2,7 @@ import './../../index.css';
2
2
  import { useRef, useState } from 'react';
3
3
  import { useDrag } from '@use-gesture/react';
4
4
  import { animate } from 'motion/react';
5
- import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
5
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
6
6
  import { EASE_BASE } from '../animations.js';
7
7
  import { isScaleBiggerThanFit, clamp } from '../utils.js';
8
8
 
@@ -35,7 +35,7 @@ const useSwipeToClose = (globalContext) => {
35
35
  (viewPortDimensions.height / 2 +
36
36
  (controller.contentSize.get()?.height ?? 0) / 2 +
37
37
  PREVIEW_BAR_HEIGHT), {
38
- duration: tokenSemanticAnimationTimeMDuration / 1000,
38
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
39
39
  ease: EASE_BASE,
40
40
  onComplete: () => {
41
41
  setIsSwipeClosing(false);
@@ -46,12 +46,12 @@ const useSwipeToClose = (globalContext) => {
46
46
  else {
47
47
  ignoreGestureRef.current = true;
48
48
  animate(globalContext.closeProgress, 0, {
49
- duration: tokenSemanticAnimationTimeMDuration / 1000,
49
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
50
50
  ease: EASE_BASE,
51
51
  onComplete: () => setIsSwipeClosing(false),
52
52
  });
53
53
  animate(controller.offsetY, 0, {
54
- duration: tokenSemanticAnimationTimeMDuration / 1000,
54
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
55
55
  ease: EASE_BASE,
56
56
  });
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useSwipeToClose.js","sources":["src/internal/hooks/useSwipeToClose.ts"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { useDrag } from '@use-gesture/react';\nimport { animate } from 'motion/react';\n\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { clamp, isScaleBiggerThanFit } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nconst PREVIEW_BAR_HEIGHT = 112;\n\nexport const useSwipeToClose = <T>(\n globalContext: MediaViewerContextValue\n): [ReturnType<typeof useDrag<T>>, boolean] => {\n const ignoreGestureRef = useRef<boolean>(true);\n const startCloseProgressRef = useRef<number>(0);\n const [isSwipeClosing, setIsSwipeClosing] = useState(false);\n\n return [\n useDrag<T>(\n (state) => {\n const controller = globalContext.currentSlideController.get();\n if (state.first) {\n controller?.offsetY.stop();\n ignoreGestureRef.current = !controller || isScaleBiggerThanFit(controller);\n startCloseProgressRef.current = globalContext.closeProgress.get();\n }\n\n if (ignoreGestureRef.current || !controller) {\n return;\n }\n\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n if (!viewPortDimensions) {\n return;\n }\n\n setIsSwipeClosing(true);\n globalContext.closeProgress.set(\n clamp(\n Math.abs(state.offset[1]) / (viewPortDimensions.height / 3) + startCloseProgressRef.current,\n 0,\n 1\n )\n );\n\n controller.offsetY.set(state.offset[1]);\n\n if (state.last) {\n if (globalContext.closeProgress.get() >= 1) {\n animate(\n controller.offsetY,\n Math.sign(state.offset[1]) *\n (viewPortDimensions.height / 2 +\n (controller.contentSize.get()?.height ?? 0) / 2 +\n PREVIEW_BAR_HEIGHT),\n {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n onComplete: () => {\n setIsSwipeClosing(false);\n globalContext.close();\n },\n }\n );\n } else {\n ignoreGestureRef.current = true;\n animate(globalContext.closeProgress, 0, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n onComplete: () => setIsSwipeClosing(false),\n });\n animate(controller.offsetY, 0, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n }\n }\n },\n {\n from: () => [0, 0],\n axis: 'y',\n filterTaps: true,\n }\n ),\n isSwipeClosing,\n ];\n};\n"],"names":[],"mappings":";;;;;;;AASA,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAElB,MAAA,eAAe,GAAG,CAC3B,aAAsC,KACI;AAC1C,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;AAC/C,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAS,CAAC,CAAC,CAAC;IAChD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,OAAO;AACH,QAAA,OAAO,CACH,CAAC,KAAK,KAAI;YACN,MAAM,UAAU,GAAG,aAAa,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC;AAC9D,YAAA,IAAI,KAAK,CAAC,KAAK,EAAE;AACb,gBAAA,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;gBAC3B,gBAAgB,CAAC,OAA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K,CAAC,CAAC;4BACzB,aAAa,CAAC,KAAK,EAAE,CAAC;yBACzB;AACJ,qBAAA,CACJ,CAAC;iBACL;qBAAM;AACH,oBAAA,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;AAChC,oBAAA,OAAO,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,EAAE;wBACpC,QAAQ,EAAE,mCAAmC,GAAG,IAAI;AACpD,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,UAAU,EAAE,MAAM,iBAAiB,CAAC,KAAK,CAAC;AAC7C,qBAAA,CAAC,CAAC;AACH,oBAAA,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE;wBAC3B,QAAQ,EAAE,mCAAmC,GAAG,IAAI;AACpD,wBAAA,IAAI,EAAE,SAAS;AAClB,qBAAA,CAAC,CAAC;iBACN;aACJ;AACL,SAAC,EACD;YACI,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AAClB,YAAA,IAAI,EAAE,GAAG;AACT,YAAA,UAAU,EAAE,IAAI;SACnB,CACJ;QACD,cAAc;KACjB,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"useSwipeToClose.js","sources":["src/internal/hooks/useSwipeToClose.ts"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { useDrag } from '@use-gesture/react';\nimport { animate } from 'motion/react';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\nimport { clamp, isScaleBiggerThanFit } from '@hh.ru/magritte-ui-media-viewer/internal/utils';\n\nconst PREVIEW_BAR_HEIGHT = 112;\n\nexport const useSwipeToClose = <T>(\n globalContext: MediaViewerContextValue\n): [ReturnType<typeof useDrag<T>>, boolean] => {\n const ignoreGestureRef = useRef<boolean>(true);\n const startCloseProgressRef = useRef<number>(0);\n const [isSwipeClosing, setIsSwipeClosing] = useState(false);\n\n return [\n useDrag<T>(\n (state) => {\n const controller = globalContext.currentSlideController.get();\n if (state.first) {\n controller?.offsetY.stop();\n ignoreGestureRef.current = !controller || isScaleBiggerThanFit(controller);\n startCloseProgressRef.current = globalContext.closeProgress.get();\n }\n\n if (ignoreGestureRef.current || !controller) {\n return;\n }\n\n const viewPortDimensions = globalContext.viewPortDimensions.get();\n if (!viewPortDimensions) {\n return;\n }\n\n setIsSwipeClosing(true);\n globalContext.closeProgress.set(\n clamp(\n Math.abs(state.offset[1]) / (viewPortDimensions.height / 3) + startCloseProgressRef.current,\n 0,\n 1\n )\n );\n\n controller.offsetY.set(state.offset[1]);\n\n if (state.last) {\n if (globalContext.closeProgress.get() >= 1) {\n animate(\n controller.offsetY,\n Math.sign(state.offset[1]) *\n (viewPortDimensions.height / 2 +\n (controller.contentSize.get()?.height ?? 0) / 2 +\n PREVIEW_BAR_HEIGHT),\n {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n onComplete: () => {\n setIsSwipeClosing(false);\n globalContext.close();\n },\n }\n );\n } else {\n ignoreGestureRef.current = true;\n animate(globalContext.closeProgress, 0, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n onComplete: () => setIsSwipeClosing(false),\n });\n animate(controller.offsetY, 0, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n });\n }\n }\n },\n {\n from: () => [0, 0],\n axis: 'y',\n filterTaps: true,\n }\n ),\n isSwipeClosing,\n ];\n};\n"],"names":[],"mappings":";;;;;;;AASA,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAElB,MAAA,eAAe,GAAG,CAC3B,aAAsC,KACI;AAC1C,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;AAC/C,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAS,CAAC,CAAC,CAAC;IAChD,MA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CAAC,CAAC,CAAC,CAAC;AACtB,yBAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;AAC1B,4BAAA,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC;AAC/C,4BAAA,kBAAkB,CAAC,EAC3B;wBACI,QAAQ,EAAE,UAAU,CAAC,oCAAoC,CAAC,CAAC,QAAQ,GAAG,IAAI;AAC1E,wBAAA,IAAI,EAAE,SAAS;wBACf,UAAU,EAAE,MAAK;4BACb,iBAAiB,CAAC,KAAK,CAAC,CAAC;4BACzB,aAAa,CAAC,KAAK,EAAE,CAAC;yBACzB;AACJ,qBAAA,CACJ,CAAC;iBACL;qBAAM;AACH,oBAAA,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;AAChC,oBAAA,OAAO,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,EAAE;wBACpC,QAAQ,EAAE,UAAU,CAAC,oCAAoC,CAAC,CAAC,QAAQ,GAAG,IAAI;AAC1E,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,UAAU,EAAE,MAAM,iBAAiB,CAAC,KAAK,CAAC;AAC7C,qBAAA,CAAC,CAAC;AACH,oBAAA,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE;wBAC3B,QAAQ,EAAE,UAAU,CAAC,oCAAoC,CAAC,CAAC,QAAQ,GAAG,IAAI;AAC1E,wBAAA,IAAI,EAAE,SAAS;AAClB,qBAAA,CAAC,CAAC;iBACN;aACJ;AACL,SAAC,EACD;YACI,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AAClB,YAAA,IAAI,EAAE,GAAG;AACT,YAAA,UAAU,EAAE,IAAI;SACnB,CACJ;QACD,cAAc;KACjB,CAAC;AACN;;;;"}
@@ -1,7 +1,7 @@
1
1
  import './../../index.css';
2
2
  import { useRef, useCallback, useEffect } from 'react';
3
3
  import { animate } from 'motion/react';
4
- import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
4
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
5
5
  import { EASE_BASE } from '../animations.js';
6
6
 
7
7
  const DOUBLE_TAP_DELAY_MS = 300;
@@ -15,7 +15,7 @@ const useTapToToggleTools = (context) => {
15
15
  const hadTouchRef = useRef(false);
16
16
  const toggleTools = useCallback(() => {
17
17
  animate(context.hideToolsProgress, Math.round(context.hideToolsProgress.get()) === 0 ? 1 : 0, {
18
- duration: tokenSemanticAnimationTimeMDuration / 1000,
18
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
19
19
  ease: EASE_BASE,
20
20
  });
21
21
  }, [context]);
@@ -1 +1 @@
1
- {"version":3,"file":"useTapToToggleTools.js","sources":["src/internal/hooks/useTapToToggleTools.ts"],"sourcesContent":["import { useRef, useCallback, type TouchEvent, type MouseEvent, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\n\nconst DOUBLE_TAP_DELAY_MS = 300;\nconst TAP_MOVE_THRESHOLD = 10;\n\ninterface UseTapToToggleToolsResult {\n onTouchStart: (e: TouchEvent) => void;\n onTouchEnd: (e: TouchEvent) => void;\n onClick: (e: MouseEvent) => void;\n}\n\nconst isInteractiveTarget = (target: EventTarget | null): boolean => {\n return target instanceof Element && !!target.closest('[data-media-viewer-interactive]');\n};\n\nexport const useTapToToggleTools = (context: MediaViewerContextValue): UseTapToToggleToolsResult => {\n const tapTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const touchStartRef = useRef<{ x: number; y: number; target: EventTarget | null } | null>(null);\n const hadTouchRef = useRef<boolean>(false);\n\n const toggleTools = useCallback(() => {\n animate(context.hideToolsProgress, Math.round(context.hideToolsProgress.get()) === 0 ? 1 : 0, {\n duration: tokenSemanticAnimationTimeMDuration / 1000,\n ease: EASE_BASE,\n });\n }, [context]);\n\n const onTouchStart = useCallback((event: TouchEvent) => {\n // Помечаем что было touch-событие, чтобы игнорировать последующий click\n hadTouchRef.current = true;\n\n // Игнорируем multi-touch (pinch zoom)\n if (event.touches.length !== 1) {\n touchStartRef.current = null;\n return;\n }\n\n const touch = event.touches[0];\n touchStartRef.current = { x: touch.clientX, y: touch.clientY, target: event.target };\n }, []);\n\n const onTouchEnd = useCallback(\n (event: TouchEvent) => {\n const touchStart = touchStartRef.current;\n touchStartRef.current = null;\n\n // Если не было валидного touchStart или это multi-touch\n if (!touchStart || event.changedTouches.length !== 1) {\n return;\n }\n\n // Проверяем интерактивный элемент\n if (isInteractiveTarget(touchStart.target)) {\n return;\n }\n\n const touch = event.changedTouches[0];\n const dx = touch.clientX - touchStart.x;\n const dy = touch.clientY - touchStart.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n // Это был свайп, не тап\n if (distance > TAP_MOVE_THRESHOLD) {\n return;\n }\n\n // Это двойной тап - отменяем pending toggle\n if (tapTimerRef.current) {\n clearTimeout(tapTimerRef.current);\n tapTimerRef.current = null;\n return;\n }\n\n // Single tap — ждём возможный второй\n tapTimerRef.current = setTimeout(() => {\n tapTimerRef.current = null;\n toggleTools();\n }, DOUBLE_TAP_DELAY_MS);\n },\n [toggleTools]\n );\n\n const onClick = useCallback(\n (event: MouseEvent) => {\n // Игнорируем click после touch (браузер генерирует оба)\n if (hadTouchRef.current) {\n hadTouchRef.current = false;\n return;\n }\n\n if (isInteractiveTarget(event.target)) {\n return;\n }\n\n // Это двойной клик - отменяем pending toggle\n if (tapTimerRef.current) {\n clearTimeout(tapTimerRef.current);\n tapTimerRef.current = null;\n return;\n }\n\n // Single click - ждём возможный второй\n tapTimerRef.current = setTimeout(() => {\n tapTimerRef.current = null;\n toggleTools();\n }, DOUBLE_TAP_DELAY_MS);\n },\n [toggleTools]\n );\n\n useE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AAmB,CAAC,CAAC;AAC5B,KAAC,EACD,CAAC,WAAW,CAAC,CAChB,CAAC;AAEF,IAAA,MAAM,OAAO,GAAG,WAAW,CACvB,CAAC,KAAiB,KAAI;;AAElB,QAAA,IAAI,WAAW,CAAC,OAAO,EAAE;AACrB,YAAA,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;YAC5B,OAAO;SACV;AAED,QAAA,IAAI,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YACnC,OAAO;SACV;;AAGD,QAAA,IAAI,WAAW,CAAC,OAAO,EAAE;AACrB,YAAA,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC,YAAA,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;YAC3B,OAAO;SACV;;AAGD,QAAA,WAAW,CAAC,OAAO,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;AAC3B,YAAA,WAAW,EAAE,CAAC;SACjB,EAAE,mBAAmB,CAAC,CAAC;AAC5B,KAAC,EACD,CAAC,WAAW,CAAC,CAChB,CAAC;AAEF,IAAA,SAAS,CACL,MAAM,MAAK;QACP,WAAW,CAAC,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KAC5D,EACD,EAAE,CACL,CAAC;AAEF,IAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACjD;;;;"}
1
+ {"version":3,"file":"useTapToToggleTools.js","sources":["src/internal/hooks/useTapToToggleTools.ts"],"sourcesContent":["import { useRef, useCallback, type TouchEvent, type MouseEvent, useEffect } from 'react';\nimport { animate } from 'motion/react';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport { EASE_BASE } from '@hh.ru/magritte-ui-media-viewer/internal/animations';\nimport { type MediaViewerContextValue } from '@hh.ru/magritte-ui-media-viewer/internal/context';\n\nconst DOUBLE_TAP_DELAY_MS = 300;\nconst TAP_MOVE_THRESHOLD = 10;\n\ninterface UseTapToToggleToolsResult {\n onTouchStart: (e: TouchEvent) => void;\n onTouchEnd: (e: TouchEvent) => void;\n onClick: (e: MouseEvent) => void;\n}\n\nconst isInteractiveTarget = (target: EventTarget | null): boolean => {\n return target instanceof Element && !!target.closest('[data-media-viewer-interactive]');\n};\n\nexport const useTapToToggleTools = (context: MediaViewerContextValue): UseTapToToggleToolsResult => {\n const tapTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const touchStartRef = useRef<{ x: number; y: number; target: EventTarget | null } | null>(null);\n const hadTouchRef = useRef<boolean>(false);\n\n const toggleTools = useCallback(() => {\n animate(context.hideToolsProgress, Math.round(context.hideToolsProgress.get()) === 0 ? 1 : 0, {\n duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,\n ease: EASE_BASE,\n });\n }, [context]);\n\n const onTouchStart = useCallback((event: TouchEvent) => {\n // Помечаем что было touch-событие, чтобы игнорировать последующий click\n hadTouchRef.current = true;\n\n // Игнорируем multi-touch (pinch zoom)\n if (event.touches.length !== 1) {\n touchStartRef.current = null;\n return;\n }\n\n const touch = event.touches[0];\n touchStartRef.current = { x: touch.clientX, y: touch.clientY, target: event.target };\n }, []);\n\n const onTouchEnd = useCallback(\n (event: TouchEvent) => {\n const touchStart = touchStartRef.current;\n touchStartRef.current = null;\n\n // Если не было валидного touchStart или это multi-touch\n if (!touchStart || event.changedTouches.length !== 1) {\n return;\n }\n\n // Проверяем интерактивный элемент\n if (isInteractiveTarget(touchStart.target)) {\n return;\n }\n\n const touch = event.changedTouches[0];\n const dx = touch.clientX - touchStart.x;\n const dy = touch.clientY - touchStart.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n // Это был свайп, не тап\n if (distance > TAP_MOVE_THRESHOLD) {\n return;\n }\n\n // Это двойной тап - отменяем pending toggle\n if (tapTimerRef.current) {\n clearTimeout(tapTimerRef.current);\n tapTimerRef.current = null;\n return;\n }\n\n // Single tap — ждём возможный второй\n tapTimerRef.current = setTimeout(() => {\n tapTimerRef.current = null;\n toggleTools();\n }, DOUBLE_TAP_DELAY_MS);\n },\n [toggleTools]\n );\n\n const onClick = useCallback(\n (event: MouseEvent) => {\n // Игнорируем click после touch (браузер генерирует оба)\n if (hadTouchRef.current) {\n hadTouchRef.current = false;\n return;\n }\n\n if (isInteractiveTarget(event.target)) {\n return;\n }\n\n // Это двойной клик - отменяем pending toggle\n if (tapTimerRef.current) {\n clearTimeout(tapTimerRef.current);\n tapTimerRef.current = null;\n return;\n }\n\n // Single click - ждём возможный второй\n tapTimerRef.current = setTimeout(() => {\n tapTimerRef.current = null;\n toggleTools();\n }, DOUBLE_TAP_DELAY_MS);\n },\n [toggleTools]\n );\n\n useEffect(\n () => () => {\n tapTimerRef.current && clearTimeout(tapTimerRef.current);\n },\n []\n );\n\n return { onTouchStart, onTouchEnd, onClick };\n};\n"],"names":[],"mappings":";;;;;AAOA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAQ9B,MAAM,mBAAmB,GAAG,CAAC,MAA0B,KAAa;AAChE,IAAA,OAAO,MAAM,YAAY,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;AAC5F,CAAC,CAAC;AAEW,MAAA,mBAAmB,GAAG,CAAC,OAAgC,KAA+B;AAC/F,IAAA,MAAM,WAAW,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;AACvE,IAAA,MAAM,aAAa,GAAG,MAAM,CAA8D,IAAI,CAAC,CAAC;AAChG,IAAA,MAAM,WAAW,GAAG,MAAM,CAAU,KAAK,CAAC,CAAC;AAE3C,IAAA,MAAM,WAAW,GAAG,WAAW,CAAC,MAAK;QACjC,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,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AC,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KAC5D,EACD,EAAE,CACL,CAAC;AAEF,IAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACjD;;;;"}
@@ -2,7 +2,7 @@ import './../../index.css';
2
2
  import { useRef, useEffect, useState } from 'react';
3
3
  import { motionValue, useMotionValueEvent } from 'motion/react';
4
4
  import { useInitOnce } from '../utils.js';
5
- import '@hh.ru/magritte-design-tokens/types';
5
+ import '@hh.ru/magritte-design-tokens/core-tokens';
6
6
  import '../animations.js';
7
7
 
8
8
  const calcVisibleRange = (currentIndex, batchSize) => {
@@ -2,7 +2,7 @@ import './../../index.css';
2
2
  import { useRef, useEffect } from 'react';
3
3
  import { useInitOnce, calcOriginOffset, clamp, lerp, animateOffsetClamp } from '../utils.js';
4
4
  import 'motion/react';
5
- import '@hh.ru/magritte-design-tokens/types';
5
+ import '@hh.ru/magritte-design-tokens/core-tokens';
6
6
  import '../animations.js';
7
7
 
8
8
  const useWheelToZoom = (controller, dimensions) => {
package/internal/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import './../index.css';
2
2
  import { useRef } from 'react';
3
3
  import { useMotionValueEvent, animate } from 'motion/react';
4
- import { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';
4
+ import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
5
5
  import { EASE_BASE } from './animations.js';
6
6
 
7
7
  const useInitOnce = (initializer) => {
@@ -72,18 +72,21 @@ const animateOffsetClamp = (controller, dimensions, anchorPoint) => {
72
72
  const clampedOffsetY = clampOffset(offset.y, sizeAfterRotation.height * scale, viewPortDimensions.height);
73
73
  if (!isClose(controller.offsetX.get(), clampedOffsetX)) {
74
74
  animate(controller.offsetX, clampedOffsetX, {
75
- duration: tokenSemanticAnimationTimeMDuration / 1000,
75
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
76
76
  ease: EASE_BASE,
77
77
  });
78
78
  }
79
79
  if (!isClose(controller.offsetY.get(), clampedOffsetY)) {
80
80
  animate(controller.offsetY, clampedOffsetY, {
81
- duration: tokenSemanticAnimationTimeMDuration / 1000,
81
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
82
82
  ease: EASE_BASE,
83
83
  });
84
84
  }
85
85
  if (!isClose(controller.scale.get(), scale)) {
86
- animate(controller.scale, scale, { duration: tokenSemanticAnimationTimeMDuration / 1000, ease: EASE_BASE });
86
+ animate(controller.scale, scale, {
87
+ duration: CoreTokens['magritte-semantic-animation-time-m'].duration / 1000,
88
+ ease: EASE_BASE,
89
+ });
87
90
  }
88
91
  };
89
92
  const isScaleBiggerThanFit = (controller) => {