@cntrl-site/components 0.1.6-19 → 0.1.6-21
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.
|
@@ -72,6 +72,14 @@ export declare const ControlImageRevealSliderComponent: {
|
|
|
72
72
|
};
|
|
73
73
|
enum: string[];
|
|
74
74
|
};
|
|
75
|
+
target: {
|
|
76
|
+
type: string;
|
|
77
|
+
title: string;
|
|
78
|
+
display: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
enum: string[];
|
|
82
|
+
};
|
|
75
83
|
defaultCursor: {
|
|
76
84
|
type: string[];
|
|
77
85
|
title: string;
|
|
@@ -127,13 +135,7 @@ export declare const ControlImageRevealSliderComponent: {
|
|
|
127
135
|
};
|
|
128
136
|
visible: {
|
|
129
137
|
type: string;
|
|
130
|
-
|
|
131
|
-
type: string;
|
|
132
|
-
};
|
|
133
|
-
enum: string[];
|
|
134
|
-
};
|
|
135
|
-
target: {
|
|
136
|
-
type: string;
|
|
138
|
+
title: string;
|
|
137
139
|
display: {
|
|
138
140
|
type: string;
|
|
139
141
|
};
|
|
@@ -153,6 +155,7 @@ export declare const ControlImageRevealSliderComponent: {
|
|
|
153
155
|
};
|
|
154
156
|
cursor: {
|
|
155
157
|
cursorType: string;
|
|
158
|
+
target: string;
|
|
156
159
|
defaultCursor: null;
|
|
157
160
|
defaultCursorScale: number;
|
|
158
161
|
hoverCursor: null;
|
|
@@ -161,7 +164,6 @@ export declare const ControlImageRevealSliderComponent: {
|
|
|
161
164
|
position: {
|
|
162
165
|
revealPosition: string;
|
|
163
166
|
visible: string;
|
|
164
|
-
target: string;
|
|
165
167
|
};
|
|
166
168
|
};
|
|
167
169
|
displayRules: ({
|
|
@@ -14,6 +14,7 @@ type ImageRevealSliderImageSize = {
|
|
|
14
14
|
};
|
|
15
15
|
type ImageRevealSliderCursor = {
|
|
16
16
|
cursorType: 'system' | 'custom';
|
|
17
|
+
target: 'area' | 'image';
|
|
17
18
|
defaultCursorScale: number;
|
|
18
19
|
defaultCursor: string | null;
|
|
19
20
|
hoverCursorScale: number;
|
|
@@ -22,7 +23,6 @@ type ImageRevealSliderCursor = {
|
|
|
22
23
|
type ImageRevealSliderPosition = {
|
|
23
24
|
revealPosition: 'random' | 'same' | 'on Click';
|
|
24
25
|
visible: 'all' | 'last One';
|
|
25
|
-
target: 'area' | 'image';
|
|
26
26
|
};
|
|
27
27
|
type ImageRevealSliderSettings = {
|
|
28
28
|
imageSize: ImageRevealSliderImageSize;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const reactSplide = require("@splidejs/react-splide");
|
|
6
6
|
const cn = require("classnames");
|
|
7
|
-
const framerMotion = require("framer-motion");
|
|
8
7
|
const reactDom = require("react-dom");
|
|
9
8
|
const wrapper = "ControlSlider-module__wrapper___sHEkd";
|
|
10
9
|
const sliderItem = "ControlSlider-module__sliderItem___QQSkR";
|
|
@@ -1041,12 +1040,10 @@ const ControlSliderComponent = {
|
|
|
1041
1040
|
const imageRevealSlider = "ImageRevealSlider-module__imageRevealSlider___UE5Ob";
|
|
1042
1041
|
const image = "ImageRevealSlider-module__image___Qjt-e";
|
|
1043
1042
|
const link = "ImageRevealSlider-module__link___N-iLG";
|
|
1044
|
-
const cursor = "ImageRevealSlider-module__cursor___2U03d";
|
|
1045
1043
|
const styles = {
|
|
1046
1044
|
imageRevealSlider,
|
|
1047
1045
|
image,
|
|
1048
|
-
link
|
|
1049
|
-
cursor
|
|
1046
|
+
link
|
|
1050
1047
|
};
|
|
1051
1048
|
function isMouseOverImage(mouseX, mouseY, placedImages) {
|
|
1052
1049
|
for (const img2 of placedImages) {
|
|
@@ -1094,23 +1091,20 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1094
1091
|
const [placedImages, setPlacedImages] = React.useState([]);
|
|
1095
1092
|
const [counter, setCounter] = React.useState(0);
|
|
1096
1093
|
const imageIdCounter = React.useRef(0);
|
|
1097
|
-
const defaultImageCount = 1;
|
|
1098
|
-
const lastMousePos = React.useRef({ x: 0, y: 0 });
|
|
1099
|
-
const [isInside, setIsInside] = React.useState(false);
|
|
1100
|
-
const cursorX = framerMotion.useMotionValue(-100);
|
|
1101
|
-
const cursorY = framerMotion.useMotionValue(-100);
|
|
1102
1094
|
const defaultScale = 32;
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1095
|
+
const [cursorCenter, setCursorCenter] = React.useState({ x: -100, y: -100 });
|
|
1096
|
+
const [cursorSize, setCursorSize] = React.useState({ w: 32, h: 32 });
|
|
1105
1097
|
const [customCursorImg, setCustomCursorImg] = React.useState("none");
|
|
1098
|
+
const lastMousePos = React.useRef({ x: 0, y: 0 });
|
|
1099
|
+
const [isInside, setIsInside] = React.useState(false);
|
|
1106
1100
|
React.useEffect(() => {
|
|
1107
1101
|
if (!divRef) return;
|
|
1108
1102
|
const updateCursorPosition = (clientX, clientY) => {
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1103
|
+
const rect = divRef.getBoundingClientRect();
|
|
1104
|
+
setCursorCenter({
|
|
1105
|
+
x: clientX - rect.left,
|
|
1106
|
+
y: clientY - rect.top
|
|
1107
|
+
});
|
|
1114
1108
|
};
|
|
1115
1109
|
const mouseMove = (e) => {
|
|
1116
1110
|
e.stopPropagation();
|
|
@@ -1127,64 +1121,49 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1127
1121
|
divRef.removeEventListener("mousemove", mouseMove);
|
|
1128
1122
|
window.removeEventListener("scroll", handleScroll, true);
|
|
1129
1123
|
};
|
|
1130
|
-
}, [
|
|
1124
|
+
}, [divRef, isInside]);
|
|
1131
1125
|
React.useEffect(() => {
|
|
1132
1126
|
if (!isInside) {
|
|
1133
1127
|
setCustomCursorImg("none");
|
|
1134
|
-
|
|
1135
|
-
cursorH.set(0);
|
|
1128
|
+
setCursorSize({ w: 0, h: 0 });
|
|
1136
1129
|
}
|
|
1137
1130
|
}, [isInside]);
|
|
1138
1131
|
const { sizeType, imageWidth: customWidth, randomRangeImageWidth: randomRange } = settings.imageSize;
|
|
1139
|
-
const { revealPosition, visible
|
|
1140
|
-
const { cursorType, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1132
|
+
const { revealPosition, visible } = settings.position;
|
|
1133
|
+
const { cursorType, target, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1141
1134
|
React.useEffect(() => {
|
|
1142
1135
|
const updateCursor = () => {
|
|
1136
|
+
if (!divRef) return;
|
|
1143
1137
|
if (cursorType === "system") {
|
|
1144
1138
|
setCustomCursorImg("none");
|
|
1145
|
-
|
|
1146
|
-
cursorH.set(defaultScale);
|
|
1139
|
+
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1147
1140
|
return;
|
|
1148
1141
|
}
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1142
|
+
const cx = cursorCenter.x;
|
|
1143
|
+
const cy = cursorCenter.y;
|
|
1144
|
+
const rect = divRef.getBoundingClientRect();
|
|
1145
|
+
const el = document.elementFromPoint(
|
|
1146
|
+
rect.left + cx,
|
|
1147
|
+
rect.top + cy
|
|
1148
|
+
);
|
|
1149
|
+
if (el && el.closest("a")) {
|
|
1151
1150
|
setCustomCursorImg("none");
|
|
1152
|
-
|
|
1153
|
-
cursorH.set(defaultScale);
|
|
1151
|
+
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1154
1152
|
return;
|
|
1155
1153
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
cursorH.set(defaultScale * hoverCursorScale || 1);
|
|
1160
|
-
} else if (isMouseOverImage(cursorX.get() + cursorW.get() / 2, cursorY.get() + cursorH.get() / 2, placedImages)) {
|
|
1161
|
-
setCustomCursorImg(hoverCursor || "none");
|
|
1162
|
-
cursorW.set(defaultScale * hoverCursorScale || 1);
|
|
1163
|
-
cursorH.set(defaultScale * hoverCursorScale || 1);
|
|
1164
|
-
} else {
|
|
1165
|
-
setCustomCursorImg(defaultCursor || "none");
|
|
1166
|
-
cursorW.set(defaultScale * defaultCursorScale || 1);
|
|
1167
|
-
cursorH.set(defaultScale * defaultCursorScale || 1);
|
|
1168
|
-
}
|
|
1154
|
+
const next = isMouseOverImage(cx, cy, placedImages) || target === "area" ? { img: hoverCursor ?? "none", w: defaultScale * hoverCursorScale, h: defaultScale * hoverCursorScale } : { img: defaultCursor ?? "none", w: defaultScale * defaultCursorScale, h: defaultScale * defaultCursorScale };
|
|
1155
|
+
setCustomCursorImg(next.img);
|
|
1156
|
+
setCursorSize({ w: next.w, h: next.h });
|
|
1169
1157
|
};
|
|
1170
|
-
const unsubscribeX = cursorX.onChange(updateCursor);
|
|
1171
|
-
const unsubscribeY = cursorY.onChange(updateCursor);
|
|
1172
1158
|
updateCursor();
|
|
1173
|
-
return () => {
|
|
1174
|
-
unsubscribeX();
|
|
1175
|
-
unsubscribeY();
|
|
1176
|
-
};
|
|
1177
1159
|
}, [
|
|
1160
|
+
cursorCenter,
|
|
1178
1161
|
cursorType,
|
|
1179
1162
|
target,
|
|
1180
1163
|
hoverCursor,
|
|
1181
1164
|
defaultCursor,
|
|
1182
1165
|
hoverCursorScale,
|
|
1183
1166
|
defaultCursorScale,
|
|
1184
|
-
cursorX,
|
|
1185
|
-
cursorY,
|
|
1186
|
-
cursorW,
|
|
1187
|
-
cursorH,
|
|
1188
1167
|
placedImages
|
|
1189
1168
|
]);
|
|
1190
1169
|
const createNewImage = async (imgData, containerWidth, containerHeight, position = {}) => {
|
|
@@ -1215,7 +1194,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1215
1194
|
};
|
|
1216
1195
|
};
|
|
1217
1196
|
const defaultContentUrls = React.useMemo(() => {
|
|
1218
|
-
const defaultContentLength = Math.min(content.length,
|
|
1197
|
+
const defaultContentLength = Math.min(content.length, 1);
|
|
1219
1198
|
return content.filter((_, i) => i < defaultContentLength).map((c) => c.image.url).join("-");
|
|
1220
1199
|
}, [content]);
|
|
1221
1200
|
React.useEffect(() => {
|
|
@@ -1225,13 +1204,13 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1225
1204
|
const containerHeight = rect.height;
|
|
1226
1205
|
const defaultPlaced = [];
|
|
1227
1206
|
const placeImages = async () => {
|
|
1228
|
-
for (let i = 0; i <
|
|
1207
|
+
for (let i = 0; i < 1 && i < content.length; i++) {
|
|
1229
1208
|
const imgData = content[i];
|
|
1230
1209
|
const newImg = await createNewImage(imgData, containerWidth, containerHeight);
|
|
1231
1210
|
defaultPlaced.push(newImg);
|
|
1232
1211
|
}
|
|
1233
1212
|
setPlacedImages(defaultPlaced);
|
|
1234
|
-
setCounter(
|
|
1213
|
+
setCounter(1 % content.length);
|
|
1235
1214
|
};
|
|
1236
1215
|
placeImages();
|
|
1237
1216
|
}, [defaultContentUrls, sizeType, customWidth, randomRange, revealPosition, divRef]);
|
|
@@ -1305,18 +1284,21 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1305
1284
|
},
|
|
1306
1285
|
img2.id
|
|
1307
1286
|
)),
|
|
1308
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1309
|
-
|
|
1287
|
+
isInside && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1288
|
+
"div",
|
|
1310
1289
|
{
|
|
1311
|
-
className:
|
|
1290
|
+
className: "cursor",
|
|
1312
1291
|
style: {
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
width:
|
|
1316
|
-
height:
|
|
1292
|
+
left: `${cursorCenter.x}px`,
|
|
1293
|
+
top: `${cursorCenter.y}px`,
|
|
1294
|
+
width: cursorSize.w,
|
|
1295
|
+
height: cursorSize.h,
|
|
1296
|
+
transform: "translate(-50%, -50%)",
|
|
1317
1297
|
backgroundImage: `url('${customCursorImg}')`,
|
|
1318
1298
|
backgroundSize: "cover",
|
|
1319
|
-
backgroundPosition: "center"
|
|
1299
|
+
backgroundPosition: "center",
|
|
1300
|
+
position: "absolute",
|
|
1301
|
+
pointerEvents: "none"
|
|
1320
1302
|
}
|
|
1321
1303
|
}
|
|
1322
1304
|
)
|
|
@@ -1397,6 +1379,14 @@ const ControlImageRevealSliderComponent = {
|
|
|
1397
1379
|
},
|
|
1398
1380
|
enum: ["system", "custom"]
|
|
1399
1381
|
},
|
|
1382
|
+
target: {
|
|
1383
|
+
type: "string",
|
|
1384
|
+
title: "Target",
|
|
1385
|
+
display: {
|
|
1386
|
+
type: "ratio-group"
|
|
1387
|
+
},
|
|
1388
|
+
enum: ["area", "image"]
|
|
1389
|
+
},
|
|
1400
1390
|
defaultCursor: {
|
|
1401
1391
|
type: ["string", "null"],
|
|
1402
1392
|
title: "Default",
|
|
@@ -1452,17 +1442,11 @@ const ControlImageRevealSliderComponent = {
|
|
|
1452
1442
|
},
|
|
1453
1443
|
visible: {
|
|
1454
1444
|
type: "string",
|
|
1445
|
+
title: "Visible",
|
|
1455
1446
|
display: {
|
|
1456
1447
|
type: "ratio-group"
|
|
1457
1448
|
},
|
|
1458
1449
|
enum: ["all", "last One"]
|
|
1459
|
-
},
|
|
1460
|
-
target: {
|
|
1461
|
-
type: "string",
|
|
1462
|
-
display: {
|
|
1463
|
-
type: "ratio-group"
|
|
1464
|
-
},
|
|
1465
|
-
enum: ["area", "image"]
|
|
1466
1450
|
}
|
|
1467
1451
|
}
|
|
1468
1452
|
}
|
|
@@ -1478,6 +1462,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1478
1462
|
},
|
|
1479
1463
|
cursor: {
|
|
1480
1464
|
cursorType: "system",
|
|
1465
|
+
target: "area",
|
|
1481
1466
|
defaultCursor: null,
|
|
1482
1467
|
defaultCursorScale: 2,
|
|
1483
1468
|
hoverCursor: null,
|
|
@@ -1485,8 +1470,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1485
1470
|
},
|
|
1486
1471
|
position: {
|
|
1487
1472
|
revealPosition: "random",
|
|
1488
|
-
visible: "all"
|
|
1489
|
-
target: "area"
|
|
1473
|
+
visible: "all"
|
|
1490
1474
|
}
|
|
1491
1475
|
},
|
|
1492
1476
|
displayRules: [
|
|
@@ -1512,7 +1496,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1512
1496
|
},
|
|
1513
1497
|
{
|
|
1514
1498
|
if: [
|
|
1515
|
-
{ name: "
|
|
1499
|
+
{ name: "cursor.target", value: "image" },
|
|
1516
1500
|
{ name: "cursor.cursorType", value: "custom" }
|
|
1517
1501
|
],
|
|
1518
1502
|
then: {
|
|
@@ -1522,7 +1506,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1522
1506
|
},
|
|
1523
1507
|
{
|
|
1524
1508
|
if: [
|
|
1525
|
-
{ name: "
|
|
1509
|
+
{ name: "cursor.target", value: "image" },
|
|
1526
1510
|
{ name: "cursor.cursorType", value: "custom" },
|
|
1527
1511
|
{ name: "cursor.defaultCursor", value: null, isNotEqual: true }
|
|
1528
1512
|
],
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { useState, useEffect, useRef, useMemo, useCallback } from "react";
|
|
3
3
|
import { Splide, SplideSlide } from "@splidejs/react-splide";
|
|
4
4
|
import cn from "classnames";
|
|
5
|
-
import { useMotionValue, motion } from "framer-motion";
|
|
6
5
|
import { createPortal } from "react-dom";
|
|
7
6
|
const wrapper = "ControlSlider-module__wrapper___sHEkd";
|
|
8
7
|
const sliderItem = "ControlSlider-module__sliderItem___QQSkR";
|
|
@@ -1039,12 +1038,10 @@ const ControlSliderComponent = {
|
|
|
1039
1038
|
const imageRevealSlider = "ImageRevealSlider-module__imageRevealSlider___UE5Ob";
|
|
1040
1039
|
const image = "ImageRevealSlider-module__image___Qjt-e";
|
|
1041
1040
|
const link = "ImageRevealSlider-module__link___N-iLG";
|
|
1042
|
-
const cursor = "ImageRevealSlider-module__cursor___2U03d";
|
|
1043
1041
|
const styles = {
|
|
1044
1042
|
imageRevealSlider,
|
|
1045
1043
|
image,
|
|
1046
|
-
link
|
|
1047
|
-
cursor
|
|
1044
|
+
link
|
|
1048
1045
|
};
|
|
1049
1046
|
function isMouseOverImage(mouseX, mouseY, placedImages) {
|
|
1050
1047
|
for (const img2 of placedImages) {
|
|
@@ -1092,23 +1089,20 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1092
1089
|
const [placedImages, setPlacedImages] = useState([]);
|
|
1093
1090
|
const [counter, setCounter] = useState(0);
|
|
1094
1091
|
const imageIdCounter = useRef(0);
|
|
1095
|
-
const defaultImageCount = 1;
|
|
1096
|
-
const lastMousePos = useRef({ x: 0, y: 0 });
|
|
1097
|
-
const [isInside, setIsInside] = useState(false);
|
|
1098
|
-
const cursorX = useMotionValue(-100);
|
|
1099
|
-
const cursorY = useMotionValue(-100);
|
|
1100
1092
|
const defaultScale = 32;
|
|
1101
|
-
const
|
|
1102
|
-
const
|
|
1093
|
+
const [cursorCenter, setCursorCenter] = useState({ x: -100, y: -100 });
|
|
1094
|
+
const [cursorSize, setCursorSize] = useState({ w: 32, h: 32 });
|
|
1103
1095
|
const [customCursorImg, setCustomCursorImg] = useState("none");
|
|
1096
|
+
const lastMousePos = useRef({ x: 0, y: 0 });
|
|
1097
|
+
const [isInside, setIsInside] = useState(false);
|
|
1104
1098
|
useEffect(() => {
|
|
1105
1099
|
if (!divRef) return;
|
|
1106
1100
|
const updateCursorPosition = (clientX, clientY) => {
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1101
|
+
const rect = divRef.getBoundingClientRect();
|
|
1102
|
+
setCursorCenter({
|
|
1103
|
+
x: clientX - rect.left,
|
|
1104
|
+
y: clientY - rect.top
|
|
1105
|
+
});
|
|
1112
1106
|
};
|
|
1113
1107
|
const mouseMove = (e) => {
|
|
1114
1108
|
e.stopPropagation();
|
|
@@ -1125,64 +1119,49 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1125
1119
|
divRef.removeEventListener("mousemove", mouseMove);
|
|
1126
1120
|
window.removeEventListener("scroll", handleScroll, true);
|
|
1127
1121
|
};
|
|
1128
|
-
}, [
|
|
1122
|
+
}, [divRef, isInside]);
|
|
1129
1123
|
useEffect(() => {
|
|
1130
1124
|
if (!isInside) {
|
|
1131
1125
|
setCustomCursorImg("none");
|
|
1132
|
-
|
|
1133
|
-
cursorH.set(0);
|
|
1126
|
+
setCursorSize({ w: 0, h: 0 });
|
|
1134
1127
|
}
|
|
1135
1128
|
}, [isInside]);
|
|
1136
1129
|
const { sizeType, imageWidth: customWidth, randomRangeImageWidth: randomRange } = settings.imageSize;
|
|
1137
|
-
const { revealPosition, visible
|
|
1138
|
-
const { cursorType, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1130
|
+
const { revealPosition, visible } = settings.position;
|
|
1131
|
+
const { cursorType, target, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1139
1132
|
useEffect(() => {
|
|
1140
1133
|
const updateCursor = () => {
|
|
1134
|
+
if (!divRef) return;
|
|
1141
1135
|
if (cursorType === "system") {
|
|
1142
1136
|
setCustomCursorImg("none");
|
|
1143
|
-
|
|
1144
|
-
cursorH.set(defaultScale);
|
|
1137
|
+
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1145
1138
|
return;
|
|
1146
1139
|
}
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1140
|
+
const cx = cursorCenter.x;
|
|
1141
|
+
const cy = cursorCenter.y;
|
|
1142
|
+
const rect = divRef.getBoundingClientRect();
|
|
1143
|
+
const el = document.elementFromPoint(
|
|
1144
|
+
rect.left + cx,
|
|
1145
|
+
rect.top + cy
|
|
1146
|
+
);
|
|
1147
|
+
if (el && el.closest("a")) {
|
|
1149
1148
|
setCustomCursorImg("none");
|
|
1150
|
-
|
|
1151
|
-
cursorH.set(defaultScale);
|
|
1149
|
+
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1152
1150
|
return;
|
|
1153
1151
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
cursorH.set(defaultScale * hoverCursorScale || 1);
|
|
1158
|
-
} else if (isMouseOverImage(cursorX.get() + cursorW.get() / 2, cursorY.get() + cursorH.get() / 2, placedImages)) {
|
|
1159
|
-
setCustomCursorImg(hoverCursor || "none");
|
|
1160
|
-
cursorW.set(defaultScale * hoverCursorScale || 1);
|
|
1161
|
-
cursorH.set(defaultScale * hoverCursorScale || 1);
|
|
1162
|
-
} else {
|
|
1163
|
-
setCustomCursorImg(defaultCursor || "none");
|
|
1164
|
-
cursorW.set(defaultScale * defaultCursorScale || 1);
|
|
1165
|
-
cursorH.set(defaultScale * defaultCursorScale || 1);
|
|
1166
|
-
}
|
|
1152
|
+
const next = isMouseOverImage(cx, cy, placedImages) || target === "area" ? { img: hoverCursor ?? "none", w: defaultScale * hoverCursorScale, h: defaultScale * hoverCursorScale } : { img: defaultCursor ?? "none", w: defaultScale * defaultCursorScale, h: defaultScale * defaultCursorScale };
|
|
1153
|
+
setCustomCursorImg(next.img);
|
|
1154
|
+
setCursorSize({ w: next.w, h: next.h });
|
|
1167
1155
|
};
|
|
1168
|
-
const unsubscribeX = cursorX.onChange(updateCursor);
|
|
1169
|
-
const unsubscribeY = cursorY.onChange(updateCursor);
|
|
1170
1156
|
updateCursor();
|
|
1171
|
-
return () => {
|
|
1172
|
-
unsubscribeX();
|
|
1173
|
-
unsubscribeY();
|
|
1174
|
-
};
|
|
1175
1157
|
}, [
|
|
1158
|
+
cursorCenter,
|
|
1176
1159
|
cursorType,
|
|
1177
1160
|
target,
|
|
1178
1161
|
hoverCursor,
|
|
1179
1162
|
defaultCursor,
|
|
1180
1163
|
hoverCursorScale,
|
|
1181
1164
|
defaultCursorScale,
|
|
1182
|
-
cursorX,
|
|
1183
|
-
cursorY,
|
|
1184
|
-
cursorW,
|
|
1185
|
-
cursorH,
|
|
1186
1165
|
placedImages
|
|
1187
1166
|
]);
|
|
1188
1167
|
const createNewImage = async (imgData, containerWidth, containerHeight, position = {}) => {
|
|
@@ -1213,7 +1192,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1213
1192
|
};
|
|
1214
1193
|
};
|
|
1215
1194
|
const defaultContentUrls = useMemo(() => {
|
|
1216
|
-
const defaultContentLength = Math.min(content.length,
|
|
1195
|
+
const defaultContentLength = Math.min(content.length, 1);
|
|
1217
1196
|
return content.filter((_, i) => i < defaultContentLength).map((c) => c.image.url).join("-");
|
|
1218
1197
|
}, [content]);
|
|
1219
1198
|
useEffect(() => {
|
|
@@ -1223,13 +1202,13 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1223
1202
|
const containerHeight = rect.height;
|
|
1224
1203
|
const defaultPlaced = [];
|
|
1225
1204
|
const placeImages = async () => {
|
|
1226
|
-
for (let i = 0; i <
|
|
1205
|
+
for (let i = 0; i < 1 && i < content.length; i++) {
|
|
1227
1206
|
const imgData = content[i];
|
|
1228
1207
|
const newImg = await createNewImage(imgData, containerWidth, containerHeight);
|
|
1229
1208
|
defaultPlaced.push(newImg);
|
|
1230
1209
|
}
|
|
1231
1210
|
setPlacedImages(defaultPlaced);
|
|
1232
|
-
setCounter(
|
|
1211
|
+
setCounter(1 % content.length);
|
|
1233
1212
|
};
|
|
1234
1213
|
placeImages();
|
|
1235
1214
|
}, [defaultContentUrls, sizeType, customWidth, randomRange, revealPosition, divRef]);
|
|
@@ -1303,18 +1282,21 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1303
1282
|
},
|
|
1304
1283
|
img2.id
|
|
1305
1284
|
)),
|
|
1306
|
-
/* @__PURE__ */ jsx(
|
|
1307
|
-
|
|
1285
|
+
isInside && /* @__PURE__ */ jsx(
|
|
1286
|
+
"div",
|
|
1308
1287
|
{
|
|
1309
|
-
className:
|
|
1288
|
+
className: "cursor",
|
|
1310
1289
|
style: {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
width:
|
|
1314
|
-
height:
|
|
1290
|
+
left: `${cursorCenter.x}px`,
|
|
1291
|
+
top: `${cursorCenter.y}px`,
|
|
1292
|
+
width: cursorSize.w,
|
|
1293
|
+
height: cursorSize.h,
|
|
1294
|
+
transform: "translate(-50%, -50%)",
|
|
1315
1295
|
backgroundImage: `url('${customCursorImg}')`,
|
|
1316
1296
|
backgroundSize: "cover",
|
|
1317
|
-
backgroundPosition: "center"
|
|
1297
|
+
backgroundPosition: "center",
|
|
1298
|
+
position: "absolute",
|
|
1299
|
+
pointerEvents: "none"
|
|
1318
1300
|
}
|
|
1319
1301
|
}
|
|
1320
1302
|
)
|
|
@@ -1395,6 +1377,14 @@ const ControlImageRevealSliderComponent = {
|
|
|
1395
1377
|
},
|
|
1396
1378
|
enum: ["system", "custom"]
|
|
1397
1379
|
},
|
|
1380
|
+
target: {
|
|
1381
|
+
type: "string",
|
|
1382
|
+
title: "Target",
|
|
1383
|
+
display: {
|
|
1384
|
+
type: "ratio-group"
|
|
1385
|
+
},
|
|
1386
|
+
enum: ["area", "image"]
|
|
1387
|
+
},
|
|
1398
1388
|
defaultCursor: {
|
|
1399
1389
|
type: ["string", "null"],
|
|
1400
1390
|
title: "Default",
|
|
@@ -1450,17 +1440,11 @@ const ControlImageRevealSliderComponent = {
|
|
|
1450
1440
|
},
|
|
1451
1441
|
visible: {
|
|
1452
1442
|
type: "string",
|
|
1443
|
+
title: "Visible",
|
|
1453
1444
|
display: {
|
|
1454
1445
|
type: "ratio-group"
|
|
1455
1446
|
},
|
|
1456
1447
|
enum: ["all", "last One"]
|
|
1457
|
-
},
|
|
1458
|
-
target: {
|
|
1459
|
-
type: "string",
|
|
1460
|
-
display: {
|
|
1461
|
-
type: "ratio-group"
|
|
1462
|
-
},
|
|
1463
|
-
enum: ["area", "image"]
|
|
1464
1448
|
}
|
|
1465
1449
|
}
|
|
1466
1450
|
}
|
|
@@ -1476,6 +1460,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1476
1460
|
},
|
|
1477
1461
|
cursor: {
|
|
1478
1462
|
cursorType: "system",
|
|
1463
|
+
target: "area",
|
|
1479
1464
|
defaultCursor: null,
|
|
1480
1465
|
defaultCursorScale: 2,
|
|
1481
1466
|
hoverCursor: null,
|
|
@@ -1483,8 +1468,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1483
1468
|
},
|
|
1484
1469
|
position: {
|
|
1485
1470
|
revealPosition: "random",
|
|
1486
|
-
visible: "all"
|
|
1487
|
-
target: "area"
|
|
1471
|
+
visible: "all"
|
|
1488
1472
|
}
|
|
1489
1473
|
},
|
|
1490
1474
|
displayRules: [
|
|
@@ -1510,7 +1494,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1510
1494
|
},
|
|
1511
1495
|
{
|
|
1512
1496
|
if: [
|
|
1513
|
-
{ name: "
|
|
1497
|
+
{ name: "cursor.target", value: "image" },
|
|
1514
1498
|
{ name: "cursor.cursorType", value: "custom" }
|
|
1515
1499
|
],
|
|
1516
1500
|
then: {
|
|
@@ -1520,7 +1504,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1520
1504
|
},
|
|
1521
1505
|
{
|
|
1522
1506
|
if: [
|
|
1523
|
-
{ name: "
|
|
1507
|
+
{ name: "cursor.target", value: "image" },
|
|
1524
1508
|
{ name: "cursor.cursorType", value: "custom" },
|
|
1525
1509
|
{ name: "cursor.defaultCursor", value: null, isNotEqual: true }
|
|
1526
1510
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/components",
|
|
3
|
-
"version": "0.1.6-
|
|
3
|
+
"version": "0.1.6-21",
|
|
4
4
|
"description": "Custom components for control editor and public websites.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"@antfu/eslint-config": "^3.16.0",
|
|
48
48
|
"@splidejs/react-splide": "^0.7.12",
|
|
49
49
|
"classnames": "^2.5.1",
|
|
50
|
-
"framer-motion": "^12.23.27",
|
|
51
50
|
"ts-node": "^10.9.1"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|