argous 1.2.217 → 1.2.218

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.
@@ -1,11 +0,0 @@
1
- export interface ZoomProps {
2
- /**
3
- * ID
4
- */
5
- id: string
6
- }
7
-
8
-
9
- declare function Zoom(props: ZoomProps) : JSX.Element
10
-
11
- export default Zoom;
@@ -1,56 +0,0 @@
1
- import clsx from 'clsx';
2
- import React, { useCallback, useEffect, useState } from 'react';
3
- import './style.css';
4
-
5
-
6
- const Zoom = ({ id, children }) => {
7
-
8
- const figureId = (id) ? `${id}-zoom-figure` : 'zoom-figure';
9
- const [active, setActive] = useState(false);
10
-
11
- const copyMediaUrl = useCallback(() => {
12
- const figureElement = document.getElementById(figureId);
13
- const mediaElement = figureElement.children?.[0];
14
- if (mediaElement) figureElement.style.backgroundImage = "url('" + mediaElement.src + "')";
15
- }, [figureId]);
16
- useEffect(() => setTimeout(() => copyMediaUrl(), 500), [copyMediaUrl]);
17
-
18
- function zoom(e, activeParameter) {
19
- if (active || activeParameter) {
20
- let offsetX, offsetY, x, y;
21
- const figureElement = document.getElementById(figureId);
22
-
23
- if (figureElement) {
24
- if (e?.nativeEvent?.offsetX) offsetX = e.nativeEvent.offsetX;
25
- else offsetX = e?.touches?.[0].pageX;
26
- if (e?.nativeEvent?.offsetY) offsetY = e.nativeEvent.offsetY;
27
- else offsetX = e?.touches?.[0].pageX;
28
-
29
- x = ((offsetX / figureElement.offsetWidth) * 100);
30
- y = ((offsetY / figureElement.offsetHeight) * 100);
31
-
32
- figureElement.style.backgroundPosition = `${x}% ${y}%`;
33
- }
34
- }
35
- }
36
-
37
- const handleActive = e => {
38
- const state = !active;
39
- setActive(state);
40
- (state) && zoom(e, state);
41
- };
42
-
43
-
44
- return <figure
45
- id={figureId}
46
- onMouseMove={zoom}
47
- onTouchMove={zoom}
48
- onClick={handleActive}
49
- className={clsx('zoom-figure', { 'zoom-figure-active': active })}
50
- >
51
- {children}
52
- </figure>;
53
- };
54
-
55
-
56
- export default Zoom;
@@ -1,2 +0,0 @@
1
- export { default } from './Zoom';
2
- export * from './Zoom';
@@ -1 +0,0 @@
1
- export { default } from './Zoom';
@@ -1,25 +0,0 @@
1
- figure.zoom-figure {
2
- position: relative;
3
- overflow: hidden;
4
- cursor: zoom-in;
5
- cursor: -moz-zoom-in;
6
- cursor: -webkit-zoom-in;
7
- background-repeat: no-repeat;
8
- background-position: 50% 50%;
9
-
10
- img {
11
- transition: opacity 250ms;
12
- display: block;
13
- width: 100%;
14
- }
15
- }
16
-
17
- figure.zoom-figure-active {
18
- cursor: zoom-out;
19
- cursor: -moz-zoom-out;
20
- cursor: -webkit-zoom-out;
21
-
22
- & img:hover {
23
- opacity: 0;
24
- }
25
- }