@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.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-5";
132
+ var version = "1.1.28";
133
133
 
134
134
  var Subscription = /** @class */ (function () {
135
135
  function Subscription(listeners, listener) {
@@ -666,18 +666,25 @@ 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
676
  document.removeEventListener('scroll', onScroll);
675
677
  setTimeout(function () {
678
+ pendingAnimation = false;
676
679
  element.style.transition = '';
677
680
  element.style.transitionDelay = '';
678
681
  }, (animation.duration * 1000 + (animation.delay || 0)) * 1000 + 100);
679
682
  });
680
683
  }
684
+ else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
685
+ // we want to repeat the animation everytime the the element is out of vide and back again
686
+ triggered = false;
687
+ }
681
688
  }
682
689
  // TODO: roll all of these in one for more efficiency of checking all the rects
683
690
  var onScroll = throttle(immediateOnScroll, 200, { leading: false });
@@ -685,7 +692,7 @@ var Animator = /** @class */ (function () {
685
692
  function isScrolledIntoView(elem) {
686
693
  var rect = elem.getBoundingClientRect();
687
694
  var windowHeight = window.innerHeight;
688
- var thresholdPrecent = 0;
695
+ var thresholdPrecent = animation.thresholdPrecent || 0;
689
696
  var threshold = thresholdPrecent * windowHeight;
690
697
  // TODO: partial in view? or what if element is larger than screen itself
691
698
  return (rect.bottom > threshold && rect.top < windowHeight - threshold // Element is peeking top or bottom
@@ -1113,6 +1120,7 @@ var Builder = /** @class */ (function () {
1113
1120
  this.observersByKey = {};
1114
1121
  this.noEditorUpdates = {};
1115
1122
  this.overrides = {};
1123
+ this.queryOptions = {};
1116
1124
  this.getContentQueue = null;
1117
1125
  this.priorContentQueue = null;
1118
1126
  this.testCookiePrefix = 'builder.tests';
@@ -1134,6 +1142,11 @@ var Builder = /** @class */ (function () {
1134
1142
  }
1135
1143
  if (isBrowser) {
1136
1144
  this.bindMessageListeners();
1145
+ if (Builder.isEditing) {
1146
+ parent.postMessage({ type: 'builder.animatorOptions', data: { options: {
1147
+ version: 2
1148
+ } } }, '*');
1149
+ }
1137
1150
  // TODO: postmessage to parent the builder info for every package
1138
1151
  // type: 'builder.sdk', data: { name: '@builder.io/react', version: '0.1.23' }
1139
1152
  // (window as any).BUILDER_VERSION = Builder.VERSION;
@@ -1724,10 +1737,14 @@ var Builder = /** @class */ (function () {
1724
1737
  var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1725
1738
  var builder = params.builder;
1726
1739
  if (builder) {
1727
- 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;
1740
+ 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;
1728
1741
  if (userAttributes) {
1729
1742
  this.setUserAttributes(userAttributes);
1730
1743
  }
1744
+ if (options) {
1745
+ // picking only locale and includeRefs
1746
+ this.queryOptions = tslib.__assign(tslib.__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs }));
1747
+ }
1731
1748
  if (overrides) {
1732
1749
  this.overrides = overrides;
1733
1750
  }
@@ -2199,9 +2216,9 @@ var Builder = /** @class */ (function () {
2199
2216
  var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
2200
2217
  // TODO: do this on every request send?
2201
2218
  this.getOverridesFromQueryString();
2202
- var queryParams = tslib.__assign({
2219
+ var queryParams = tslib.__assign(tslib.__assign({
2203
2220
  // TODO: way to force a request to be in a separate queue. or just lower queue limit to be 1 by default
2204
- omit: queue[0].omit || 'meta.componentsUsed', apiKey: this.apiKey }, queue[0].options);
2221
+ omit: queue[0].omit || 'meta.componentsUsed', apiKey: this.apiKey }, queue[0].options), this.queryOptions);
2205
2222
  if (queue[0].fields) {
2206
2223
  queryParams.fields = queue[0].fields;
2207
2224
  }