argous 1.2.216 → 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.
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ var clsx_1 = __importDefault(require("clsx"));
26
+ var react_1 = __importStar(require("react"));
27
+ require("./style.css");
28
+ var Zoom = function (_a) {
29
+ var id = _a.id, children = _a.children;
30
+ var figureId = (id) ? id + "-zoom-figure" : 'zoom-figure';
31
+ var _b = react_1.useState(false), active = _b[0], setActive = _b[1];
32
+ var copyMediaUrl = react_1.useCallback(function () {
33
+ var _a;
34
+ var figureElement = document.getElementById(figureId);
35
+ var mediaElement = (_a = figureElement.children) === null || _a === void 0 ? void 0 : _a[0];
36
+ if (mediaElement)
37
+ figureElement.style.backgroundImage = "url('" + mediaElement.src + "')";
38
+ }, [figureId]);
39
+ react_1.useEffect(function () { return setTimeout(function () { return copyMediaUrl(); }, 500); }, [copyMediaUrl]);
40
+ function zoom(e, activeParameter) {
41
+ var _a, _b, _c, _d;
42
+ if (active || activeParameter) {
43
+ var offsetX = void 0, offsetY = void 0, x = void 0, y = void 0;
44
+ var figureElement = document.getElementById(figureId);
45
+ if (figureElement) {
46
+ if ((_a = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _a === void 0 ? void 0 : _a.offsetX)
47
+ offsetX = e.nativeEvent.offsetX;
48
+ else
49
+ offsetX = (_b = e === null || e === void 0 ? void 0 : e.touches) === null || _b === void 0 ? void 0 : _b[0].pageX;
50
+ if ((_c = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _c === void 0 ? void 0 : _c.offsetY)
51
+ offsetY = e.nativeEvent.offsetY;
52
+ else
53
+ offsetX = (_d = e === null || e === void 0 ? void 0 : e.touches) === null || _d === void 0 ? void 0 : _d[0].pageX;
54
+ x = ((offsetX / figureElement.offsetWidth) * 100);
55
+ y = ((offsetY / figureElement.offsetHeight) * 100);
56
+ figureElement.style.backgroundPosition = x + "% " + y + "%";
57
+ }
58
+ }
59
+ }
60
+ var handleActive = function (e) {
61
+ var state = !active;
62
+ setActive(state);
63
+ (state) && zoom(e, state);
64
+ };
65
+ return react_1.default.createElement("figure", { id: figureId, onMouseMove: zoom, onTouchMove: zoom, onClick: handleActive, className: clsx_1.default('zoom-figure', { 'zoom-figure-active': active }) }, children);
66
+ };
67
+ exports.default = Zoom;
@@ -0,0 +1,2 @@
1
+ export { default } from './Zoom';
2
+ export * from './Zoom';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
7
+ var Zoom_1 = require("./Zoom");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Zoom_1).default; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.216",
3
+ "version": "1.2.218",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",