@builder.io/sdk 1.1.29 → 1.1.30

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.cjs.js CHANGED
@@ -129,7 +129,7 @@ function assertAllowedPropertyName(name) {
129
129
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
130
130
  }
131
131
 
132
- var version = "1.1.28";
132
+ var version = "1.1.30-1";
133
133
 
134
134
  var Subscription = /** @class */ (function () {
135
135
  function Subscription(listeners, listener) {
@@ -666,18 +666,33 @@ var Animator = /** @class */ (function () {
666
666
  Array.from(elements).forEach(function (element) {
667
667
  _this.augmentAnimation(animation, element);
668
668
  var triggered = false;
669
+ var pendingAnimation = false;
669
670
  function immediateOnScroll() {
670
671
  if (!triggered && isScrolledIntoView(element)) {
671
672
  triggered = true;
673
+ pendingAnimation = true;
672
674
  setTimeout(function () {
673
675
  assign(element.style, animation.steps[1].styles);
674
- document.removeEventListener('scroll', onScroll);
676
+ if (!animation.repeat) {
677
+ document.removeEventListener('scroll', onScroll);
678
+ }
675
679
  setTimeout(function () {
676
- element.style.transition = '';
677
- element.style.transitionDelay = '';
678
- }, (animation.duration * 1000 + (animation.delay || 0)) * 1000 + 100);
680
+ pendingAnimation = false;
681
+ if (!animation.repeat) {
682
+ element.style.transition = '';
683
+ element.style.transitionDelay = '';
684
+ }
685
+ }, (animation.duration + (animation.delay || 0)) * 1000 + 100);
679
686
  });
680
687
  }
688
+ else if (animation.repeat &&
689
+ triggered &&
690
+ !pendingAnimation &&
691
+ !isScrolledIntoView(element)) {
692
+ // we want to repeat the animation every time the the element is out of view and back again
693
+ triggered = false;
694
+ assign(element.style, animation.steps[0].styles);
695
+ }
681
696
  }
682
697
  // TODO: roll all of these in one for more efficiency of checking all the rects
683
698
  var onScroll = throttle(immediateOnScroll, 200, { leading: false });
@@ -685,8 +700,8 @@ var Animator = /** @class */ (function () {
685
700
  function isScrolledIntoView(elem) {
686
701
  var rect = elem.getBoundingClientRect();
687
702
  var windowHeight = window.innerHeight;
688
- var thresholdPrecent = 0;
689
- var threshold = thresholdPrecent * windowHeight;
703
+ var thresholdPercent = (animation.thresholdPercent || 0) / 100;
704
+ var threshold = thresholdPercent * windowHeight;
690
705
  // TODO: partial in view? or what if element is larger than screen itself
691
706
  return (rect.bottom > threshold && rect.top < windowHeight - threshold // Element is peeking top or bottom
692
707
  // (rect.top > 0 && rect.bottom < window.innerHeight) || // element fits within the screen and is fully on screen (not hanging off at all)
@@ -1135,6 +1150,16 @@ var Builder = /** @class */ (function () {
1135
1150
  }
1136
1151
  if (isBrowser) {
1137
1152
  this.bindMessageListeners();
1153
+ if (Builder.isEditing) {
1154
+ parent.postMessage({
1155
+ type: 'builder.animatorOptions',
1156
+ data: {
1157
+ options: {
1158
+ version: 2,
1159
+ },
1160
+ },
1161
+ }, '*');
1162
+ }
1138
1163
  // TODO: postmessage to parent the builder info for every package
1139
1164
  // type: 'builder.sdk', data: { name: '@builder.io/react', version: '0.1.23' }
1140
1165
  // (window as any).BUILDER_VERSION = Builder.VERSION;