@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.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";
155
+ var version = "1.1.30-1";
156
156
 
157
157
  var Subscription = /** @class */ (function () {
158
158
  function Subscription(listeners, listener) {
@@ -689,18 +689,33 @@
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 () {
699
- element.style.transition = '';
700
- element.style.transitionDelay = '';
701
- }, (animation.duration * 1000 + (animation.delay || 0)) * 1000 + 100);
703
+ pendingAnimation = false;
704
+ if (!animation.repeat) {
705
+ element.style.transition = '';
706
+ element.style.transitionDelay = '';
707
+ }
708
+ }, (animation.duration + (animation.delay || 0)) * 1000 + 100);
702
709
  });
703
710
  }
711
+ else if (animation.repeat &&
712
+ triggered &&
713
+ !pendingAnimation &&
714
+ !isScrolledIntoView(element)) {
715
+ // we want to repeat the animation every time the the element is out of view and back again
716
+ triggered = false;
717
+ assign(element.style, animation.steps[0].styles);
718
+ }
704
719
  }
705
720
  // TODO: roll all of these in one for more efficiency of checking all the rects
706
721
  var onScroll = throttle(immediateOnScroll, 200, { leading: false });
@@ -708,8 +723,8 @@
708
723
  function isScrolledIntoView(elem) {
709
724
  var rect = elem.getBoundingClientRect();
710
725
  var windowHeight = window.innerHeight;
711
- var thresholdPrecent = 0;
712
- var threshold = thresholdPrecent * windowHeight;
726
+ var thresholdPercent = (animation.thresholdPercent || 0) / 100;
727
+ var threshold = thresholdPercent * windowHeight;
713
728
  // TODO: partial in view? or what if element is larger than screen itself
714
729
  return (rect.bottom > threshold && rect.top < windowHeight - threshold // Element is peeking top or bottom
715
730
  // (rect.top > 0 && rect.bottom < window.innerHeight) || // element fits within the screen and is fully on screen (not hanging off at all)
@@ -1226,6 +1241,16 @@
1226
1241
  }
1227
1242
  if (isBrowser) {
1228
1243
  this.bindMessageListeners();
1244
+ if (Builder.isEditing) {
1245
+ parent.postMessage({
1246
+ type: 'builder.animatorOptions',
1247
+ data: {
1248
+ options: {
1249
+ version: 2,
1250
+ },
1251
+ },
1252
+ }, '*');
1253
+ }
1229
1254
  // TODO: postmessage to parent the builder info for every package
1230
1255
  // type: 'builder.sdk', data: { name: '@builder.io/react', version: '0.1.23' }
1231
1256
  // (window as any).BUILDER_VERSION = Builder.VERSION;