@builder.io/sdk-solid 0.12.6 → 0.12.7
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.d.ts +18 -1
- package/lib/browser/dev.js +221 -1
- package/lib/browser/dev.jsx +233 -11
- package/lib/browser/index.js +220 -1
- package/lib/browser/index.jsx +232 -11
- package/lib/edge/dev.js +221 -1
- package/lib/edge/dev.jsx +233 -11
- package/lib/edge/index.js +220 -1
- package/lib/edge/index.jsx +232 -11
- package/lib/node/dev.js +221 -1
- package/lib/node/dev.jsx +233 -11
- package/lib/node/index.js +220 -1
- package/lib/node/index.jsx +232 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,23 @@ interface JSONObject$1 {
|
|
|
6
6
|
}
|
|
7
7
|
interface JSONArray$1 extends Array<JSONValue$1> {
|
|
8
8
|
}
|
|
9
|
+
interface AnimationStep {
|
|
10
|
+
styles: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
delay?: number;
|
|
14
|
+
}
|
|
15
|
+
interface BuilderAnimation {
|
|
16
|
+
elementId: string;
|
|
17
|
+
trigger: string;
|
|
18
|
+
steps: AnimationStep[];
|
|
19
|
+
duration: number;
|
|
20
|
+
delay?: number;
|
|
21
|
+
easing?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
repeat?: boolean;
|
|
24
|
+
thresholdPercent?: number;
|
|
25
|
+
}
|
|
9
26
|
/** @todo typedoc this */
|
|
10
27
|
interface BuilderBlock {
|
|
11
28
|
'@type': '@builder.io/sdk:Element';
|
|
@@ -54,7 +71,7 @@ interface BuilderBlock {
|
|
|
54
71
|
collection: string;
|
|
55
72
|
itemName?: string;
|
|
56
73
|
} | null;
|
|
57
|
-
animations?:
|
|
74
|
+
animations?: BuilderAnimation[];
|
|
58
75
|
style?: Partial<CSSStyleDeclaration>;
|
|
59
76
|
href?: string;
|
|
60
77
|
/**
|
package/lib/browser/dev.js
CHANGED
|
@@ -423,6 +423,212 @@ function getProcessedBlock({
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
// src/components/block/animator.ts
|
|
427
|
+
function throttle(func, wait, options = {}) {
|
|
428
|
+
let context;
|
|
429
|
+
let args;
|
|
430
|
+
let result;
|
|
431
|
+
let timeout = null;
|
|
432
|
+
let previous = 0;
|
|
433
|
+
const later = function() {
|
|
434
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
435
|
+
timeout = null;
|
|
436
|
+
result = func.apply(context, args);
|
|
437
|
+
if (!timeout)
|
|
438
|
+
context = args = null;
|
|
439
|
+
};
|
|
440
|
+
return function() {
|
|
441
|
+
const now = Date.now();
|
|
442
|
+
if (!previous && options.leading === false)
|
|
443
|
+
previous = now;
|
|
444
|
+
const remaining = wait - (now - previous);
|
|
445
|
+
context = this;
|
|
446
|
+
args = arguments;
|
|
447
|
+
if (remaining <= 0 || remaining > wait) {
|
|
448
|
+
if (timeout) {
|
|
449
|
+
clearTimeout(timeout);
|
|
450
|
+
timeout = null;
|
|
451
|
+
}
|
|
452
|
+
previous = now;
|
|
453
|
+
result = func.apply(context, args);
|
|
454
|
+
if (!timeout)
|
|
455
|
+
context = args = null;
|
|
456
|
+
} else if (!timeout && options.trailing !== false) {
|
|
457
|
+
timeout = setTimeout(later, remaining);
|
|
458
|
+
}
|
|
459
|
+
return result;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function assign(target, ..._args) {
|
|
463
|
+
const to = Object(target);
|
|
464
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
465
|
+
const nextSource = arguments[index];
|
|
466
|
+
if (nextSource != null) {
|
|
467
|
+
for (const nextKey in nextSource) {
|
|
468
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
469
|
+
to[nextKey] = nextSource[nextKey];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return to;
|
|
475
|
+
}
|
|
476
|
+
var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
477
|
+
function bindAnimations(animations) {
|
|
478
|
+
for (const animation of animations) {
|
|
479
|
+
switch (animation.trigger) {
|
|
480
|
+
case "pageLoad":
|
|
481
|
+
triggerAnimation(animation);
|
|
482
|
+
break;
|
|
483
|
+
case "hover":
|
|
484
|
+
bindHoverAnimation(animation);
|
|
485
|
+
break;
|
|
486
|
+
case "scrollInView":
|
|
487
|
+
bindScrollInViewAnimation(animation);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function warnElementNotPresent(id) {
|
|
493
|
+
console.warn(`Cannot animate element: element with ID ${id} not found!`);
|
|
494
|
+
}
|
|
495
|
+
function augmentAnimation(animation, element) {
|
|
496
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
497
|
+
const computedStyle = getComputedStyle(element);
|
|
498
|
+
const firstStyles = animation.steps[0].styles;
|
|
499
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
500
|
+
const bothStyles = [firstStyles, lastStyles];
|
|
501
|
+
for (const styles of bothStyles) {
|
|
502
|
+
for (const style of stylesUsed) {
|
|
503
|
+
if (!(style in styles)) {
|
|
504
|
+
styles[style] = computedStyle[style];
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function getAllStylesUsed(animation) {
|
|
510
|
+
const properties = [];
|
|
511
|
+
for (const step of animation.steps) {
|
|
512
|
+
for (const key in step.styles) {
|
|
513
|
+
if (properties.indexOf(key) === -1) {
|
|
514
|
+
properties.push(key);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return properties;
|
|
519
|
+
}
|
|
520
|
+
function triggerAnimation(animation) {
|
|
521
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
522
|
+
if (!elements.length) {
|
|
523
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
Array.from(elements).forEach((element) => {
|
|
527
|
+
augmentAnimation(animation, element);
|
|
528
|
+
element.style.transition = "none";
|
|
529
|
+
element.style.transitionDelay = "0";
|
|
530
|
+
assign(element.style, animation.steps[0].styles);
|
|
531
|
+
setTimeout(() => {
|
|
532
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
533
|
+
if (animation.delay) {
|
|
534
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
535
|
+
}
|
|
536
|
+
assign(element.style, animation.steps[1].styles);
|
|
537
|
+
setTimeout(() => {
|
|
538
|
+
element.style.transition = "";
|
|
539
|
+
element.style.transitionDelay = "";
|
|
540
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function bindHoverAnimation(animation) {
|
|
545
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
546
|
+
if (!elements.length) {
|
|
547
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
Array.from(elements).forEach((element) => {
|
|
551
|
+
augmentAnimation(animation, element);
|
|
552
|
+
const defaultState = animation.steps[0].styles;
|
|
553
|
+
const hoverState = animation.steps[1].styles;
|
|
554
|
+
function attachDefaultState() {
|
|
555
|
+
assign(element.style, defaultState);
|
|
556
|
+
}
|
|
557
|
+
function attachHoverState() {
|
|
558
|
+
assign(element.style, hoverState);
|
|
559
|
+
}
|
|
560
|
+
attachDefaultState();
|
|
561
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
562
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
563
|
+
setTimeout(() => {
|
|
564
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
565
|
+
if (animation.delay) {
|
|
566
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function bindScrollInViewAnimation(animation) {
|
|
572
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
573
|
+
if (!elements.length) {
|
|
574
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
Array.from(elements).forEach((element) => {
|
|
578
|
+
augmentAnimation(animation, element);
|
|
579
|
+
let triggered = false;
|
|
580
|
+
let pendingAnimation = false;
|
|
581
|
+
function immediateOnScroll() {
|
|
582
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
583
|
+
triggered = true;
|
|
584
|
+
pendingAnimation = true;
|
|
585
|
+
setTimeout(() => {
|
|
586
|
+
assign(element.style, animation.steps[1].styles);
|
|
587
|
+
if (!animation.repeat) {
|
|
588
|
+
document.removeEventListener("scroll", onScroll);
|
|
589
|
+
}
|
|
590
|
+
setTimeout(() => {
|
|
591
|
+
pendingAnimation = false;
|
|
592
|
+
if (!animation.repeat) {
|
|
593
|
+
element.style.transition = "";
|
|
594
|
+
element.style.transitionDelay = "";
|
|
595
|
+
}
|
|
596
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
597
|
+
});
|
|
598
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
599
|
+
triggered = false;
|
|
600
|
+
assign(element.style, animation.steps[0].styles);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
604
|
+
leading: false
|
|
605
|
+
});
|
|
606
|
+
function isScrolledIntoView(elem) {
|
|
607
|
+
const rect = elem.getBoundingClientRect();
|
|
608
|
+
const windowHeight = window.innerHeight;
|
|
609
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
610
|
+
const threshold = thresholdPercent * windowHeight;
|
|
611
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
612
|
+
}
|
|
613
|
+
const defaultState = animation.steps[0].styles;
|
|
614
|
+
function attachDefaultState() {
|
|
615
|
+
assign(element.style, defaultState);
|
|
616
|
+
}
|
|
617
|
+
attachDefaultState();
|
|
618
|
+
setTimeout(() => {
|
|
619
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
620
|
+
if (animation.delay) {
|
|
621
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
document.addEventListener("scroll", onScroll, {
|
|
625
|
+
capture: true,
|
|
626
|
+
passive: true
|
|
627
|
+
});
|
|
628
|
+
immediateOnScroll();
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
|
|
426
632
|
// src/components/block/block.helpers.ts
|
|
427
633
|
var getComponent = ({
|
|
428
634
|
block,
|
|
@@ -998,6 +1204,16 @@ function Block(props) {
|
|
|
998
1204
|
isInteractive: !blockComponent()?.isRSC
|
|
999
1205
|
};
|
|
1000
1206
|
}
|
|
1207
|
+
onMount(() => {
|
|
1208
|
+
const blockId = processedBlock().id;
|
|
1209
|
+
const animations = processedBlock().animations;
|
|
1210
|
+
if (animations && blockId) {
|
|
1211
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
1212
|
+
...animation,
|
|
1213
|
+
elementId: blockId
|
|
1214
|
+
})));
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1001
1217
|
return createComponent(Show, {
|
|
1002
1218
|
get when() {
|
|
1003
1219
|
return canShowBlock();
|
|
@@ -3410,7 +3626,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3410
3626
|
};
|
|
3411
3627
|
|
|
3412
3628
|
// src/constants/sdk-version.ts
|
|
3413
|
-
var SDK_VERSION = "0.12.
|
|
3629
|
+
var SDK_VERSION = "0.12.7";
|
|
3414
3630
|
|
|
3415
3631
|
// src/functions/register.ts
|
|
3416
3632
|
var registry = {};
|
|
@@ -3617,6 +3833,10 @@ function EnableEditor(props) {
|
|
|
3617
3833
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
3618
3834
|
break;
|
|
3619
3835
|
}
|
|
3836
|
+
case "builder.triggerAnimation": {
|
|
3837
|
+
triggerAnimation(data.data);
|
|
3838
|
+
break;
|
|
3839
|
+
}
|
|
3620
3840
|
case "builder.contentUpdate": {
|
|
3621
3841
|
const messageContent = data.data;
|
|
3622
3842
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
package/lib/browser/dev.jsx
CHANGED
|
@@ -99,7 +99,7 @@ import { createContext as createContext2 } from "solid-js";
|
|
|
99
99
|
var components_context_default = createContext2({ registeredComponents: {} });
|
|
100
100
|
|
|
101
101
|
// src/components/block/block.tsx
|
|
102
|
-
import { Show as Show4, For as For2, createSignal as createSignal4 } from "solid-js";
|
|
102
|
+
import { Show as Show4, For as For2, onMount, createSignal as createSignal4 } from "solid-js";
|
|
103
103
|
|
|
104
104
|
// src/functions/get-block-component-options.ts
|
|
105
105
|
function getBlockComponentOptions(block) {
|
|
@@ -410,6 +410,212 @@ function getProcessedBlock({
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
// src/components/block/animator.ts
|
|
414
|
+
function throttle(func, wait, options = {}) {
|
|
415
|
+
let context;
|
|
416
|
+
let args;
|
|
417
|
+
let result;
|
|
418
|
+
let timeout = null;
|
|
419
|
+
let previous = 0;
|
|
420
|
+
const later = function() {
|
|
421
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
422
|
+
timeout = null;
|
|
423
|
+
result = func.apply(context, args);
|
|
424
|
+
if (!timeout)
|
|
425
|
+
context = args = null;
|
|
426
|
+
};
|
|
427
|
+
return function() {
|
|
428
|
+
const now = Date.now();
|
|
429
|
+
if (!previous && options.leading === false)
|
|
430
|
+
previous = now;
|
|
431
|
+
const remaining = wait - (now - previous);
|
|
432
|
+
context = this;
|
|
433
|
+
args = arguments;
|
|
434
|
+
if (remaining <= 0 || remaining > wait) {
|
|
435
|
+
if (timeout) {
|
|
436
|
+
clearTimeout(timeout);
|
|
437
|
+
timeout = null;
|
|
438
|
+
}
|
|
439
|
+
previous = now;
|
|
440
|
+
result = func.apply(context, args);
|
|
441
|
+
if (!timeout)
|
|
442
|
+
context = args = null;
|
|
443
|
+
} else if (!timeout && options.trailing !== false) {
|
|
444
|
+
timeout = setTimeout(later, remaining);
|
|
445
|
+
}
|
|
446
|
+
return result;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function assign(target, ..._args) {
|
|
450
|
+
const to = Object(target);
|
|
451
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
452
|
+
const nextSource = arguments[index];
|
|
453
|
+
if (nextSource != null) {
|
|
454
|
+
for (const nextKey in nextSource) {
|
|
455
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
456
|
+
to[nextKey] = nextSource[nextKey];
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return to;
|
|
462
|
+
}
|
|
463
|
+
var camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
464
|
+
function bindAnimations(animations) {
|
|
465
|
+
for (const animation of animations) {
|
|
466
|
+
switch (animation.trigger) {
|
|
467
|
+
case "pageLoad":
|
|
468
|
+
triggerAnimation(animation);
|
|
469
|
+
break;
|
|
470
|
+
case "hover":
|
|
471
|
+
bindHoverAnimation(animation);
|
|
472
|
+
break;
|
|
473
|
+
case "scrollInView":
|
|
474
|
+
bindScrollInViewAnimation(animation);
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function warnElementNotPresent(id) {
|
|
480
|
+
console.warn(`Cannot animate element: element with ID ${id} not found!`);
|
|
481
|
+
}
|
|
482
|
+
function augmentAnimation(animation, element) {
|
|
483
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
484
|
+
const computedStyle = getComputedStyle(element);
|
|
485
|
+
const firstStyles = animation.steps[0].styles;
|
|
486
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
487
|
+
const bothStyles = [firstStyles, lastStyles];
|
|
488
|
+
for (const styles of bothStyles) {
|
|
489
|
+
for (const style of stylesUsed) {
|
|
490
|
+
if (!(style in styles)) {
|
|
491
|
+
styles[style] = computedStyle[style];
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function getAllStylesUsed(animation) {
|
|
497
|
+
const properties = [];
|
|
498
|
+
for (const step of animation.steps) {
|
|
499
|
+
for (const key in step.styles) {
|
|
500
|
+
if (properties.indexOf(key) === -1) {
|
|
501
|
+
properties.push(key);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return properties;
|
|
506
|
+
}
|
|
507
|
+
function triggerAnimation(animation) {
|
|
508
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
509
|
+
if (!elements.length) {
|
|
510
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
Array.from(elements).forEach((element) => {
|
|
514
|
+
augmentAnimation(animation, element);
|
|
515
|
+
element.style.transition = "none";
|
|
516
|
+
element.style.transitionDelay = "0";
|
|
517
|
+
assign(element.style, animation.steps[0].styles);
|
|
518
|
+
setTimeout(() => {
|
|
519
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
520
|
+
if (animation.delay) {
|
|
521
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
522
|
+
}
|
|
523
|
+
assign(element.style, animation.steps[1].styles);
|
|
524
|
+
setTimeout(() => {
|
|
525
|
+
element.style.transition = "";
|
|
526
|
+
element.style.transitionDelay = "";
|
|
527
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
function bindHoverAnimation(animation) {
|
|
532
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
533
|
+
if (!elements.length) {
|
|
534
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
Array.from(elements).forEach((element) => {
|
|
538
|
+
augmentAnimation(animation, element);
|
|
539
|
+
const defaultState = animation.steps[0].styles;
|
|
540
|
+
const hoverState = animation.steps[1].styles;
|
|
541
|
+
function attachDefaultState() {
|
|
542
|
+
assign(element.style, defaultState);
|
|
543
|
+
}
|
|
544
|
+
function attachHoverState() {
|
|
545
|
+
assign(element.style, hoverState);
|
|
546
|
+
}
|
|
547
|
+
attachDefaultState();
|
|
548
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
549
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
550
|
+
setTimeout(() => {
|
|
551
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
552
|
+
if (animation.delay) {
|
|
553
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
function bindScrollInViewAnimation(animation) {
|
|
559
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
560
|
+
if (!elements.length) {
|
|
561
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
Array.from(elements).forEach((element) => {
|
|
565
|
+
augmentAnimation(animation, element);
|
|
566
|
+
let triggered = false;
|
|
567
|
+
let pendingAnimation = false;
|
|
568
|
+
function immediateOnScroll() {
|
|
569
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
570
|
+
triggered = true;
|
|
571
|
+
pendingAnimation = true;
|
|
572
|
+
setTimeout(() => {
|
|
573
|
+
assign(element.style, animation.steps[1].styles);
|
|
574
|
+
if (!animation.repeat) {
|
|
575
|
+
document.removeEventListener("scroll", onScroll);
|
|
576
|
+
}
|
|
577
|
+
setTimeout(() => {
|
|
578
|
+
pendingAnimation = false;
|
|
579
|
+
if (!animation.repeat) {
|
|
580
|
+
element.style.transition = "";
|
|
581
|
+
element.style.transitionDelay = "";
|
|
582
|
+
}
|
|
583
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
584
|
+
});
|
|
585
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
586
|
+
triggered = false;
|
|
587
|
+
assign(element.style, animation.steps[0].styles);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
591
|
+
leading: false
|
|
592
|
+
});
|
|
593
|
+
function isScrolledIntoView(elem) {
|
|
594
|
+
const rect = elem.getBoundingClientRect();
|
|
595
|
+
const windowHeight = window.innerHeight;
|
|
596
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
597
|
+
const threshold = thresholdPercent * windowHeight;
|
|
598
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
599
|
+
}
|
|
600
|
+
const defaultState = animation.steps[0].styles;
|
|
601
|
+
function attachDefaultState() {
|
|
602
|
+
assign(element.style, defaultState);
|
|
603
|
+
}
|
|
604
|
+
attachDefaultState();
|
|
605
|
+
setTimeout(() => {
|
|
606
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
607
|
+
if (animation.delay) {
|
|
608
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
document.addEventListener("scroll", onScroll, {
|
|
612
|
+
capture: true,
|
|
613
|
+
passive: true
|
|
614
|
+
});
|
|
615
|
+
immediateOnScroll();
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
|
|
413
619
|
// src/components/block/block.helpers.ts
|
|
414
620
|
var getComponent = ({
|
|
415
621
|
block,
|
|
@@ -932,6 +1138,18 @@ function Block(props) {
|
|
|
932
1138
|
isInteractive: !blockComponent()?.isRSC
|
|
933
1139
|
};
|
|
934
1140
|
}
|
|
1141
|
+
onMount(() => {
|
|
1142
|
+
const blockId = processedBlock().id;
|
|
1143
|
+
const animations = processedBlock().animations;
|
|
1144
|
+
if (animations && blockId) {
|
|
1145
|
+
bindAnimations(
|
|
1146
|
+
animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
1147
|
+
...animation,
|
|
1148
|
+
elementId: blockId
|
|
1149
|
+
}))
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
935
1153
|
return <Show4 when={canShowBlock()}>
|
|
936
1154
|
<Block_styles_default block={props.block} context={props.context} />
|
|
937
1155
|
<Show4
|
|
@@ -1380,10 +1598,10 @@ function SectionComponent(props) {
|
|
|
1380
1598
|
var section_default = SectionComponent;
|
|
1381
1599
|
|
|
1382
1600
|
// src/blocks/symbol/symbol.tsx
|
|
1383
|
-
import { onMount as
|
|
1601
|
+
import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal14 } from "solid-js";
|
|
1384
1602
|
|
|
1385
1603
|
// src/components/content-variants/content-variants.tsx
|
|
1386
|
-
import { Show as Show11, For as For5, onMount as
|
|
1604
|
+
import { Show as Show11, For as For5, onMount as onMount4, createSignal as createSignal13 } from "solid-js";
|
|
1387
1605
|
|
|
1388
1606
|
// src/helpers/url.ts
|
|
1389
1607
|
var getTopLevelDomain = (host) => {
|
|
@@ -1861,12 +2079,12 @@ var componentInfo3 = {
|
|
|
1861
2079
|
};
|
|
1862
2080
|
|
|
1863
2081
|
// src/blocks/custom-code/custom-code.tsx
|
|
1864
|
-
import { onMount, createSignal as createSignal7 } from "solid-js";
|
|
2082
|
+
import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
|
|
1865
2083
|
function CustomCode(props) {
|
|
1866
2084
|
const [scriptsInserted, setScriptsInserted] = createSignal7([]);
|
|
1867
2085
|
const [scriptsRun, setScriptsRun] = createSignal7([]);
|
|
1868
2086
|
let elementRef;
|
|
1869
|
-
|
|
2087
|
+
onMount2(() => {
|
|
1870
2088
|
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
1871
2089
|
return;
|
|
1872
2090
|
}
|
|
@@ -2587,7 +2805,7 @@ function InlinedScript(props) {
|
|
|
2587
2805
|
var Inlined_script_default = InlinedScript;
|
|
2588
2806
|
|
|
2589
2807
|
// src/components/content/components/enable-editor.tsx
|
|
2590
|
-
import { Show as Show9, onMount as
|
|
2808
|
+
import { Show as Show9, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
|
|
2591
2809
|
import { Dynamic as Dynamic5 } from "solid-js/web";
|
|
2592
2810
|
|
|
2593
2811
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -3082,7 +3300,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3082
3300
|
};
|
|
3083
3301
|
|
|
3084
3302
|
// src/constants/sdk-version.ts
|
|
3085
|
-
var SDK_VERSION = "0.12.
|
|
3303
|
+
var SDK_VERSION = "0.12.7";
|
|
3086
3304
|
|
|
3087
3305
|
// src/functions/register.ts
|
|
3088
3306
|
var registry = {};
|
|
@@ -3286,6 +3504,10 @@ function EnableEditor(props) {
|
|
|
3286
3504
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
3287
3505
|
break;
|
|
3288
3506
|
}
|
|
3507
|
+
case "builder.triggerAnimation": {
|
|
3508
|
+
triggerAnimation(data.data);
|
|
3509
|
+
break;
|
|
3510
|
+
}
|
|
3289
3511
|
case "builder.contentUpdate": {
|
|
3290
3512
|
const messageContent = data.data;
|
|
3291
3513
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -3383,7 +3605,7 @@ function EnableEditor(props) {
|
|
|
3383
3605
|
}
|
|
3384
3606
|
}
|
|
3385
3607
|
let elementRef;
|
|
3386
|
-
|
|
3608
|
+
onMount3(() => {
|
|
3387
3609
|
if (isBrowser()) {
|
|
3388
3610
|
if (isEditing() && true) {
|
|
3389
3611
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
@@ -3448,7 +3670,7 @@ function EnableEditor(props) {
|
|
|
3448
3670
|
}
|
|
3449
3671
|
}
|
|
3450
3672
|
});
|
|
3451
|
-
|
|
3673
|
+
onMount3(() => {
|
|
3452
3674
|
if (!props.apiKey) {
|
|
3453
3675
|
logger.error(
|
|
3454
3676
|
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
@@ -3788,7 +4010,7 @@ function ContentVariants(props) {
|
|
|
3788
4010
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
3789
4011
|
});
|
|
3790
4012
|
}
|
|
3791
|
-
|
|
4013
|
+
onMount4(() => {
|
|
3792
4014
|
setShouldRenderVariants(false);
|
|
3793
4015
|
});
|
|
3794
4016
|
return <>
|
|
@@ -3900,7 +4122,7 @@ function Symbol(props) {
|
|
|
3900
4122
|
}
|
|
3901
4123
|
});
|
|
3902
4124
|
}
|
|
3903
|
-
|
|
4125
|
+
onMount5(() => {
|
|
3904
4126
|
setContent();
|
|
3905
4127
|
});
|
|
3906
4128
|
function onUpdateFn_0() {
|