@builder.io/sdk 1.1.28-6 → 1.1.29-0

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.esm.js CHANGED
@@ -123,7 +123,7 @@ function assertAllowedPropertyName(name) {
123
123
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
124
124
  }
125
125
 
126
- var version = "1.1.28-5";
126
+ var version = "1.1.28";
127
127
 
128
128
  var Subscription = /** @class */ (function () {
129
129
  function Subscription(listeners, listener) {
@@ -660,18 +660,25 @@ var Animator = /** @class */ (function () {
660
660
  Array.from(elements).forEach(function (element) {
661
661
  _this.augmentAnimation(animation, element);
662
662
  var triggered = false;
663
+ var pendingAnimation = false;
663
664
  function immediateOnScroll() {
664
665
  if (!triggered && isScrolledIntoView(element)) {
665
666
  triggered = true;
667
+ pendingAnimation = true;
666
668
  setTimeout(function () {
667
669
  assign(element.style, animation.steps[1].styles);
668
670
  document.removeEventListener('scroll', onScroll);
669
671
  setTimeout(function () {
672
+ pendingAnimation = false;
670
673
  element.style.transition = '';
671
674
  element.style.transitionDelay = '';
672
675
  }, (animation.duration * 1000 + (animation.delay || 0)) * 1000 + 100);
673
676
  });
674
677
  }
678
+ else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
679
+ // we want to repeat the animation everytime the the element is out of vide and back again
680
+ triggered = false;
681
+ }
675
682
  }
676
683
  // TODO: roll all of these in one for more efficiency of checking all the rects
677
684
  var onScroll = throttle(immediateOnScroll, 200, { leading: false });
@@ -679,7 +686,7 @@ var Animator = /** @class */ (function () {
679
686
  function isScrolledIntoView(elem) {
680
687
  var rect = elem.getBoundingClientRect();
681
688
  var windowHeight = window.innerHeight;
682
- var thresholdPrecent = 0;
689
+ var thresholdPrecent = animation.thresholdPrecent || 0;
683
690
  var threshold = thresholdPrecent * windowHeight;
684
691
  // TODO: partial in view? or what if element is larger than screen itself
685
692
  return (rect.bottom > threshold && rect.top < windowHeight - threshold // Element is peeking top or bottom
@@ -1107,6 +1114,7 @@ var Builder = /** @class */ (function () {
1107
1114
  this.observersByKey = {};
1108
1115
  this.noEditorUpdates = {};
1109
1116
  this.overrides = {};
1117
+ this.queryOptions = {};
1110
1118
  this.getContentQueue = null;
1111
1119
  this.priorContentQueue = null;
1112
1120
  this.testCookiePrefix = 'builder.tests';
@@ -1128,6 +1136,11 @@ var Builder = /** @class */ (function () {
1128
1136
  }
1129
1137
  if (isBrowser) {
1130
1138
  this.bindMessageListeners();
1139
+ if (Builder.isEditing) {
1140
+ parent.postMessage({ type: 'builder.animatorOptions', data: { options: {
1141
+ version: 2
1142
+ } } }, '*');
1143
+ }
1131
1144
  // TODO: postmessage to parent the builder info for every package
1132
1145
  // type: 'builder.sdk', data: { name: '@builder.io/react', version: '0.1.23' }
1133
1146
  // (window as any).BUILDER_VERSION = Builder.VERSION;
@@ -1718,10 +1731,14 @@ var Builder = /** @class */ (function () {
1718
1731
  var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1719
1732
  var builder = params.builder;
1720
1733
  if (builder) {
1721
- var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env, host = builder.host, api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, overrideParams = builder.params;
1734
+ var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env, host = builder.host, api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
1722
1735
  if (userAttributes) {
1723
1736
  this.setUserAttributes(userAttributes);
1724
1737
  }
1738
+ if (options) {
1739
+ // picking only locale and includeRefs
1740
+ this.queryOptions = __assign(__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs }));
1741
+ }
1725
1742
  if (overrides) {
1726
1743
  this.overrides = overrides;
1727
1744
  }
@@ -2193,9 +2210,9 @@ var Builder = /** @class */ (function () {
2193
2210
  var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
2194
2211
  // TODO: do this on every request send?
2195
2212
  this.getOverridesFromQueryString();
2196
- var queryParams = __assign({
2213
+ var queryParams = __assign(__assign({
2197
2214
  // TODO: way to force a request to be in a separate queue. or just lower queue limit to be 1 by default
2198
- omit: queue[0].omit || 'meta.componentsUsed', apiKey: this.apiKey }, queue[0].options);
2215
+ omit: queue[0].omit || 'meta.componentsUsed', apiKey: this.apiKey }, queue[0].options), this.queryOptions);
2199
2216
  if (queue[0].fields) {
2200
2217
  queryParams.fields = queue[0].fields;
2201
2218
  }