@builder.io/sdk 1.1.28 → 1.1.29-1

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.umd.js CHANGED
@@ -152,7 +152,7 @@
152
152
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
153
153
  }
154
154
 
155
- var version = "1.1.28-5";
155
+ var version = "1.1.29-0";
156
156
 
157
157
  var Subscription = /** @class */ (function () {
158
158
  function Subscription(listeners, listener) {
@@ -689,18 +689,27 @@
689
689
  Array.from(elements).forEach(function (element) {
690
690
  _this.augmentAnimation(animation, element);
691
691
  var triggered = false;
692
+ var pendingAnimation = false;
692
693
  function immediateOnScroll() {
693
694
  if (!triggered && isScrolledIntoView(element)) {
694
695
  triggered = true;
696
+ pendingAnimation = true;
695
697
  setTimeout(function () {
696
698
  assign(element.style, animation.steps[1].styles);
697
- document.removeEventListener('scroll', onScroll);
699
+ if (!animation.repeat) {
700
+ document.removeEventListener('scroll', onScroll);
701
+ }
698
702
  setTimeout(function () {
703
+ pendingAnimation = false;
699
704
  element.style.transition = '';
700
705
  element.style.transitionDelay = '';
701
706
  }, (animation.duration * 1000 + (animation.delay || 0)) * 1000 + 100);
702
707
  });
703
708
  }
709
+ else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
710
+ // we want to repeat the animation everytime the the element is out of vide and back again
711
+ triggered = false;
712
+ }
704
713
  }
705
714
  // TODO: roll all of these in one for more efficiency of checking all the rects
706
715
  var onScroll = throttle(immediateOnScroll, 200, { leading: false });
@@ -708,7 +717,7 @@
708
717
  function isScrolledIntoView(elem) {
709
718
  var rect = elem.getBoundingClientRect();
710
719
  var windowHeight = window.innerHeight;
711
- var thresholdPrecent = 0;
720
+ var thresholdPrecent = animation.thresholdPrecent || 0;
712
721
  var threshold = thresholdPrecent * windowHeight;
713
722
  // TODO: partial in view? or what if element is larger than screen itself
714
723
  return (rect.bottom > threshold && rect.top < windowHeight - threshold // Element is peeking top or bottom
@@ -1226,6 +1235,11 @@
1226
1235
  }
1227
1236
  if (isBrowser) {
1228
1237
  this.bindMessageListeners();
1238
+ if (Builder.isEditing) {
1239
+ parent.postMessage({ type: 'builder.animatorOptions', data: { options: {
1240
+ version: 2
1241
+ } } }, '*');
1242
+ }
1229
1243
  // TODO: postmessage to parent the builder info for every package
1230
1244
  // type: 'builder.sdk', data: { name: '@builder.io/react', version: '0.1.23' }
1231
1245
  // (window as any).BUILDER_VERSION = Builder.VERSION;