@cntrl-site/components 0.1.6-20 → 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
|
@@ -1092,7 +1092,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1092
1092
|
const [counter, setCounter] = React.useState(0);
|
|
1093
1093
|
const imageIdCounter = React.useRef(0);
|
|
1094
1094
|
const defaultScale = 32;
|
|
1095
|
-
const [
|
|
1095
|
+
const [cursorCenter, setCursorCenter] = React.useState({ x: -100, y: -100 });
|
|
1096
1096
|
const [cursorSize, setCursorSize] = React.useState({ w: 32, h: 32 });
|
|
1097
1097
|
const [customCursorImg, setCustomCursorImg] = React.useState("none");
|
|
1098
1098
|
const lastMousePos = React.useRef({ x: 0, y: 0 });
|
|
@@ -1101,9 +1101,9 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1101
1101
|
if (!divRef) return;
|
|
1102
1102
|
const updateCursorPosition = (clientX, clientY) => {
|
|
1103
1103
|
const rect = divRef.getBoundingClientRect();
|
|
1104
|
-
|
|
1105
|
-
x: clientX -
|
|
1106
|
-
y: clientY -
|
|
1104
|
+
setCursorCenter({
|
|
1105
|
+
x: clientX - rect.left,
|
|
1106
|
+
y: clientY - rect.top
|
|
1107
1107
|
});
|
|
1108
1108
|
};
|
|
1109
1109
|
const mouseMove = (e) => {
|
|
@@ -1121,7 +1121,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1121
1121
|
divRef.removeEventListener("mousemove", mouseMove);
|
|
1122
1122
|
window.removeEventListener("scroll", handleScroll, true);
|
|
1123
1123
|
};
|
|
1124
|
-
}, [divRef,
|
|
1124
|
+
}, [divRef, isInside]);
|
|
1125
1125
|
React.useEffect(() => {
|
|
1126
1126
|
if (!isInside) {
|
|
1127
1127
|
setCustomCursorImg("none");
|
|
@@ -1129,8 +1129,8 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
}, [isInside]);
|
|
1131
1131
|
const { sizeType, imageWidth: customWidth, randomRangeImageWidth: randomRange } = settings.imageSize;
|
|
1132
|
-
const { revealPosition, visible
|
|
1133
|
-
const { cursorType, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1132
|
+
const { revealPosition, visible } = settings.position;
|
|
1133
|
+
const { cursorType, target, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1134
1134
|
React.useEffect(() => {
|
|
1135
1135
|
const updateCursor = () => {
|
|
1136
1136
|
if (!divRef) return;
|
|
@@ -1139,8 +1139,8 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1139
1139
|
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1140
1140
|
return;
|
|
1141
1141
|
}
|
|
1142
|
-
const cx =
|
|
1143
|
-
const cy =
|
|
1142
|
+
const cx = cursorCenter.x;
|
|
1143
|
+
const cy = cursorCenter.y;
|
|
1144
1144
|
const rect = divRef.getBoundingClientRect();
|
|
1145
1145
|
const el = document.elementFromPoint(
|
|
1146
1146
|
rect.left + cx,
|
|
@@ -1151,13 +1151,13 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1151
1151
|
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1152
1152
|
return;
|
|
1153
1153
|
}
|
|
1154
|
-
const next = isMouseOverImage(cx, cy, placedImages) || target === "area" ? { img: hoverCursor ?? "none", w: defaultScale *
|
|
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
1155
|
setCustomCursorImg(next.img);
|
|
1156
1156
|
setCursorSize({ w: next.w, h: next.h });
|
|
1157
1157
|
};
|
|
1158
1158
|
updateCursor();
|
|
1159
1159
|
}, [
|
|
1160
|
-
|
|
1160
|
+
cursorCenter,
|
|
1161
1161
|
cursorType,
|
|
1162
1162
|
target,
|
|
1163
1163
|
hoverCursor,
|
|
@@ -1289,15 +1289,15 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1289
1289
|
{
|
|
1290
1290
|
className: "cursor",
|
|
1291
1291
|
style: {
|
|
1292
|
-
|
|
1292
|
+
left: `${cursorCenter.x}px`,
|
|
1293
|
+
top: `${cursorCenter.y}px`,
|
|
1293
1294
|
width: cursorSize.w,
|
|
1294
1295
|
height: cursorSize.h,
|
|
1296
|
+
transform: "translate(-50%, -50%)",
|
|
1295
1297
|
backgroundImage: `url('${customCursorImg}')`,
|
|
1296
1298
|
backgroundSize: "cover",
|
|
1297
1299
|
backgroundPosition: "center",
|
|
1298
1300
|
position: "absolute",
|
|
1299
|
-
top: 0,
|
|
1300
|
-
left: 0,
|
|
1301
1301
|
pointerEvents: "none"
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
@@ -1379,6 +1379,14 @@ const ControlImageRevealSliderComponent = {
|
|
|
1379
1379
|
},
|
|
1380
1380
|
enum: ["system", "custom"]
|
|
1381
1381
|
},
|
|
1382
|
+
target: {
|
|
1383
|
+
type: "string",
|
|
1384
|
+
title: "Target",
|
|
1385
|
+
display: {
|
|
1386
|
+
type: "ratio-group"
|
|
1387
|
+
},
|
|
1388
|
+
enum: ["area", "image"]
|
|
1389
|
+
},
|
|
1382
1390
|
defaultCursor: {
|
|
1383
1391
|
type: ["string", "null"],
|
|
1384
1392
|
title: "Default",
|
|
@@ -1434,17 +1442,11 @@ const ControlImageRevealSliderComponent = {
|
|
|
1434
1442
|
},
|
|
1435
1443
|
visible: {
|
|
1436
1444
|
type: "string",
|
|
1445
|
+
title: "Visible",
|
|
1437
1446
|
display: {
|
|
1438
1447
|
type: "ratio-group"
|
|
1439
1448
|
},
|
|
1440
1449
|
enum: ["all", "last One"]
|
|
1441
|
-
},
|
|
1442
|
-
target: {
|
|
1443
|
-
type: "string",
|
|
1444
|
-
display: {
|
|
1445
|
-
type: "ratio-group"
|
|
1446
|
-
},
|
|
1447
|
-
enum: ["area", "image"]
|
|
1448
1450
|
}
|
|
1449
1451
|
}
|
|
1450
1452
|
}
|
|
@@ -1460,6 +1462,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1460
1462
|
},
|
|
1461
1463
|
cursor: {
|
|
1462
1464
|
cursorType: "system",
|
|
1465
|
+
target: "area",
|
|
1463
1466
|
defaultCursor: null,
|
|
1464
1467
|
defaultCursorScale: 2,
|
|
1465
1468
|
hoverCursor: null,
|
|
@@ -1467,8 +1470,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1467
1470
|
},
|
|
1468
1471
|
position: {
|
|
1469
1472
|
revealPosition: "random",
|
|
1470
|
-
visible: "all"
|
|
1471
|
-
target: "area"
|
|
1473
|
+
visible: "all"
|
|
1472
1474
|
}
|
|
1473
1475
|
},
|
|
1474
1476
|
displayRules: [
|
|
@@ -1494,7 +1496,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1494
1496
|
},
|
|
1495
1497
|
{
|
|
1496
1498
|
if: [
|
|
1497
|
-
{ name: "
|
|
1499
|
+
{ name: "cursor.target", value: "image" },
|
|
1498
1500
|
{ name: "cursor.cursorType", value: "custom" }
|
|
1499
1501
|
],
|
|
1500
1502
|
then: {
|
|
@@ -1504,7 +1506,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1504
1506
|
},
|
|
1505
1507
|
{
|
|
1506
1508
|
if: [
|
|
1507
|
-
{ name: "
|
|
1509
|
+
{ name: "cursor.target", value: "image" },
|
|
1508
1510
|
{ name: "cursor.cursorType", value: "custom" },
|
|
1509
1511
|
{ name: "cursor.defaultCursor", value: null, isNotEqual: true }
|
|
1510
1512
|
],
|
package/dist/index.mjs
CHANGED
|
@@ -1090,7 +1090,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1090
1090
|
const [counter, setCounter] = useState(0);
|
|
1091
1091
|
const imageIdCounter = useRef(0);
|
|
1092
1092
|
const defaultScale = 32;
|
|
1093
|
-
const [
|
|
1093
|
+
const [cursorCenter, setCursorCenter] = useState({ x: -100, y: -100 });
|
|
1094
1094
|
const [cursorSize, setCursorSize] = useState({ w: 32, h: 32 });
|
|
1095
1095
|
const [customCursorImg, setCustomCursorImg] = useState("none");
|
|
1096
1096
|
const lastMousePos = useRef({ x: 0, y: 0 });
|
|
@@ -1099,9 +1099,9 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1099
1099
|
if (!divRef) return;
|
|
1100
1100
|
const updateCursorPosition = (clientX, clientY) => {
|
|
1101
1101
|
const rect = divRef.getBoundingClientRect();
|
|
1102
|
-
|
|
1103
|
-
x: clientX -
|
|
1104
|
-
y: clientY -
|
|
1102
|
+
setCursorCenter({
|
|
1103
|
+
x: clientX - rect.left,
|
|
1104
|
+
y: clientY - rect.top
|
|
1105
1105
|
});
|
|
1106
1106
|
};
|
|
1107
1107
|
const mouseMove = (e) => {
|
|
@@ -1119,7 +1119,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1119
1119
|
divRef.removeEventListener("mousemove", mouseMove);
|
|
1120
1120
|
window.removeEventListener("scroll", handleScroll, true);
|
|
1121
1121
|
};
|
|
1122
|
-
}, [divRef,
|
|
1122
|
+
}, [divRef, isInside]);
|
|
1123
1123
|
useEffect(() => {
|
|
1124
1124
|
if (!isInside) {
|
|
1125
1125
|
setCustomCursorImg("none");
|
|
@@ -1127,8 +1127,8 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1127
1127
|
}
|
|
1128
1128
|
}, [isInside]);
|
|
1129
1129
|
const { sizeType, imageWidth: customWidth, randomRangeImageWidth: randomRange } = settings.imageSize;
|
|
1130
|
-
const { revealPosition, visible
|
|
1131
|
-
const { cursorType, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1130
|
+
const { revealPosition, visible } = settings.position;
|
|
1131
|
+
const { cursorType, target, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
|
|
1132
1132
|
useEffect(() => {
|
|
1133
1133
|
const updateCursor = () => {
|
|
1134
1134
|
if (!divRef) return;
|
|
@@ -1137,8 +1137,8 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1137
1137
|
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1138
1138
|
return;
|
|
1139
1139
|
}
|
|
1140
|
-
const cx =
|
|
1141
|
-
const cy =
|
|
1140
|
+
const cx = cursorCenter.x;
|
|
1141
|
+
const cy = cursorCenter.y;
|
|
1142
1142
|
const rect = divRef.getBoundingClientRect();
|
|
1143
1143
|
const el = document.elementFromPoint(
|
|
1144
1144
|
rect.left + cx,
|
|
@@ -1149,13 +1149,13 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1149
1149
|
setCursorSize({ w: defaultScale, h: defaultScale });
|
|
1150
1150
|
return;
|
|
1151
1151
|
}
|
|
1152
|
-
const next = isMouseOverImage(cx, cy, placedImages) || target === "area" ? { img: hoverCursor ?? "none", w: defaultScale *
|
|
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
1153
|
setCustomCursorImg(next.img);
|
|
1154
1154
|
setCursorSize({ w: next.w, h: next.h });
|
|
1155
1155
|
};
|
|
1156
1156
|
updateCursor();
|
|
1157
1157
|
}, [
|
|
1158
|
-
|
|
1158
|
+
cursorCenter,
|
|
1159
1159
|
cursorType,
|
|
1160
1160
|
target,
|
|
1161
1161
|
hoverCursor,
|
|
@@ -1287,15 +1287,15 @@ function ImageRevealSlider({ settings, content, isEditor }) {
|
|
|
1287
1287
|
{
|
|
1288
1288
|
className: "cursor",
|
|
1289
1289
|
style: {
|
|
1290
|
-
|
|
1290
|
+
left: `${cursorCenter.x}px`,
|
|
1291
|
+
top: `${cursorCenter.y}px`,
|
|
1291
1292
|
width: cursorSize.w,
|
|
1292
1293
|
height: cursorSize.h,
|
|
1294
|
+
transform: "translate(-50%, -50%)",
|
|
1293
1295
|
backgroundImage: `url('${customCursorImg}')`,
|
|
1294
1296
|
backgroundSize: "cover",
|
|
1295
1297
|
backgroundPosition: "center",
|
|
1296
1298
|
position: "absolute",
|
|
1297
|
-
top: 0,
|
|
1298
|
-
left: 0,
|
|
1299
1299
|
pointerEvents: "none"
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
@@ -1377,6 +1377,14 @@ const ControlImageRevealSliderComponent = {
|
|
|
1377
1377
|
},
|
|
1378
1378
|
enum: ["system", "custom"]
|
|
1379
1379
|
},
|
|
1380
|
+
target: {
|
|
1381
|
+
type: "string",
|
|
1382
|
+
title: "Target",
|
|
1383
|
+
display: {
|
|
1384
|
+
type: "ratio-group"
|
|
1385
|
+
},
|
|
1386
|
+
enum: ["area", "image"]
|
|
1387
|
+
},
|
|
1380
1388
|
defaultCursor: {
|
|
1381
1389
|
type: ["string", "null"],
|
|
1382
1390
|
title: "Default",
|
|
@@ -1432,17 +1440,11 @@ const ControlImageRevealSliderComponent = {
|
|
|
1432
1440
|
},
|
|
1433
1441
|
visible: {
|
|
1434
1442
|
type: "string",
|
|
1443
|
+
title: "Visible",
|
|
1435
1444
|
display: {
|
|
1436
1445
|
type: "ratio-group"
|
|
1437
1446
|
},
|
|
1438
1447
|
enum: ["all", "last One"]
|
|
1439
|
-
},
|
|
1440
|
-
target: {
|
|
1441
|
-
type: "string",
|
|
1442
|
-
display: {
|
|
1443
|
-
type: "ratio-group"
|
|
1444
|
-
},
|
|
1445
|
-
enum: ["area", "image"]
|
|
1446
1448
|
}
|
|
1447
1449
|
}
|
|
1448
1450
|
}
|
|
@@ -1458,6 +1460,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1458
1460
|
},
|
|
1459
1461
|
cursor: {
|
|
1460
1462
|
cursorType: "system",
|
|
1463
|
+
target: "area",
|
|
1461
1464
|
defaultCursor: null,
|
|
1462
1465
|
defaultCursorScale: 2,
|
|
1463
1466
|
hoverCursor: null,
|
|
@@ -1465,8 +1468,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1465
1468
|
},
|
|
1466
1469
|
position: {
|
|
1467
1470
|
revealPosition: "random",
|
|
1468
|
-
visible: "all"
|
|
1469
|
-
target: "area"
|
|
1471
|
+
visible: "all"
|
|
1470
1472
|
}
|
|
1471
1473
|
},
|
|
1472
1474
|
displayRules: [
|
|
@@ -1492,7 +1494,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1492
1494
|
},
|
|
1493
1495
|
{
|
|
1494
1496
|
if: [
|
|
1495
|
-
{ name: "
|
|
1497
|
+
{ name: "cursor.target", value: "image" },
|
|
1496
1498
|
{ name: "cursor.cursorType", value: "custom" }
|
|
1497
1499
|
],
|
|
1498
1500
|
then: {
|
|
@@ -1502,7 +1504,7 @@ const ControlImageRevealSliderComponent = {
|
|
|
1502
1504
|
},
|
|
1503
1505
|
{
|
|
1504
1506
|
if: [
|
|
1505
|
-
{ name: "
|
|
1507
|
+
{ name: "cursor.target", value: "image" },
|
|
1506
1508
|
{ name: "cursor.cursorType", value: "custom" },
|
|
1507
1509
|
{ name: "cursor.defaultCursor", value: null, isNotEqual: true }
|
|
1508
1510
|
],
|