@widelab-nc/widehue 1.0.36 → 1.0.37
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.
- package/dist/index.js +4 -4
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/index.js +130 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1296,6 +1296,136 @@ window.animationTest3 = function(root) {
|
|
|
1296
1296
|
});
|
|
1297
1297
|
});
|
|
1298
1298
|
};
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
window.animationTest4 = function(root) {
|
|
1302
|
+
const hoverWrappers = root.querySelectorAll('.hover-wrapper');
|
|
1303
|
+
const hoverMasks = root.querySelectorAll('.hover-mask');
|
|
1304
|
+
const hoverTitles = root.querySelectorAll('.hover-title');
|
|
1305
|
+
|
|
1306
|
+
// Stałe rozmiary bg-video
|
|
1307
|
+
const VIDEO_WIDTH = 380;
|
|
1308
|
+
const VIDEO_HEIGHT = 280;
|
|
1309
|
+
const VISIBLE_RATIO = 0.7;
|
|
1310
|
+
|
|
1311
|
+
// Ukryj wszystkie maski na starcie
|
|
1312
|
+
hoverMasks.forEach(mask => {
|
|
1313
|
+
mask.style.display = 'none';
|
|
1314
|
+
mask.style.position = 'fixed';
|
|
1315
|
+
mask.style.top = '0';
|
|
1316
|
+
mask.style.left = '0';
|
|
1317
|
+
mask.style.width = '100vw';
|
|
1318
|
+
mask.style.height = '100vh';
|
|
1319
|
+
mask.style.zIndex = '999';
|
|
1320
|
+
mask.style.pointerEvents = 'none'; // nie blokuje hovera
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
function resetOpacity() {
|
|
1324
|
+
hoverTitles.forEach(title => {
|
|
1325
|
+
title.style.opacity = '';
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function resetBgVideos(mask) {
|
|
1330
|
+
const videos = mask.querySelectorAll('.bg-video');
|
|
1331
|
+
videos.forEach(video => {
|
|
1332
|
+
video.style.display = 'none';
|
|
1333
|
+
video.style.left = '';
|
|
1334
|
+
video.style.top = '';
|
|
1335
|
+
video.style.position = '';
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function placeElementAtRandomVisiblePosition(el, container) {
|
|
1340
|
+
const containerWidth = container.offsetWidth;
|
|
1341
|
+
const containerHeight = container.offsetHeight;
|
|
1342
|
+
|
|
1343
|
+
const minVisibleWidth = VIDEO_WIDTH * VISIBLE_RATIO;
|
|
1344
|
+
const minVisibleHeight = VIDEO_HEIGHT * VISIBLE_RATIO;
|
|
1345
|
+
|
|
1346
|
+
const maxLeft = containerWidth - minVisibleWidth;
|
|
1347
|
+
const maxTop = containerHeight - minVisibleHeight;
|
|
1348
|
+
|
|
1349
|
+
let left = Math.random() * maxLeft;
|
|
1350
|
+
let top = Math.random() * maxTop;
|
|
1351
|
+
|
|
1352
|
+
if (left + VIDEO_WIDTH > containerWidth) left = containerWidth - VIDEO_WIDTH;
|
|
1353
|
+
if (top + VIDEO_HEIGHT > containerHeight) top = containerHeight - VIDEO_HEIGHT;
|
|
1354
|
+
|
|
1355
|
+
el.style.left = `${left}px`;
|
|
1356
|
+
el.style.top = `${top}px`;
|
|
1357
|
+
el.style.position = 'absolute';
|
|
1358
|
+
el.style.width = `${VIDEO_WIDTH}px`;
|
|
1359
|
+
el.style.height = `${VIDEO_HEIGHT}px`;
|
|
1360
|
+
el.style.zIndex = '1001';
|
|
1361
|
+
el.style.pointerEvents = 'none';
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
hoverWrappers.forEach((wrapper, index) => {
|
|
1365
|
+
const title = hoverTitles[index];
|
|
1366
|
+
const mask = hoverMasks[index];
|
|
1367
|
+
const videos = mask.querySelectorAll('.bg-video');
|
|
1368
|
+
let videoTimeline = null;
|
|
1369
|
+
let isActive = false;
|
|
1370
|
+
|
|
1371
|
+
videos.forEach(video => {
|
|
1372
|
+
video.style.display = 'none';
|
|
1373
|
+
video.style.width = `${VIDEO_WIDTH}px`;
|
|
1374
|
+
video.style.height = `${VIDEO_HEIGHT}px`;
|
|
1375
|
+
video.style.position = 'absolute';
|
|
1376
|
+
video.style.zIndex = '1001';
|
|
1377
|
+
video.style.pointerEvents = 'none';
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
wrapper.addEventListener('mouseenter', () => {
|
|
1381
|
+
if (isActive) return;
|
|
1382
|
+
isActive = true;
|
|
1383
|
+
|
|
1384
|
+
resetBgVideos(mask);
|
|
1385
|
+
mask.style.display = 'block';
|
|
1386
|
+
|
|
1387
|
+
hoverTitles.forEach((t, i) => {
|
|
1388
|
+
t.style.opacity = i === index ? '1' : '0.2';
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
videoTimeline = gsap.timeline();
|
|
1392
|
+
|
|
1393
|
+
videos.forEach((video, i) => {
|
|
1394
|
+
videoTimeline.add(() => {
|
|
1395
|
+
placeElementAtRandomVisiblePosition(video, mask);
|
|
1396
|
+
}, i);
|
|
1397
|
+
|
|
1398
|
+
videoTimeline.to(video, {
|
|
1399
|
+
display: 'block',
|
|
1400
|
+
duration: 0
|
|
1401
|
+
}, i);
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
videoTimeline.play();
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1407
|
+
wrapper.addEventListener('mouseleave', () => {
|
|
1408
|
+
isActive = false;
|
|
1409
|
+
|
|
1410
|
+
if (videoTimeline) {
|
|
1411
|
+
videoTimeline.kill();
|
|
1412
|
+
videoTimeline = null;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
mask.style.display = 'none';
|
|
1416
|
+
resetBgVideos(mask);
|
|
1417
|
+
|
|
1418
|
+
setTimeout(() => {
|
|
1419
|
+
const anyHovered = Array.from(hoverWrappers).some(el => el.matches(':hover'));
|
|
1420
|
+
if (!anyHovered) resetOpacity();
|
|
1421
|
+
}, 0);
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1299
1429
|
window.pricingInteraction = function(e) {
|
|
1300
1430
|
// Check if the screen width is 992px or wider
|
|
1301
1431
|
if (window.innerWidth >= 992) {
|