bhl-forms 0.1.19 → 0.1.21

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.
@@ -11274,7 +11274,25 @@ function getCoords(elem) {
11274
11274
  left: box2.left + window.pageXOffset
11275
11275
  };
11276
11276
  }
11277
+ function formVisible(formNode) {
11278
+ const form2 = document.getElementById(formNode.id);
11279
+ if (!form2) {
11280
+ return false;
11281
+ }
11282
+ let box2 = form2.getBoundingClientRect();
11283
+ if (box2.top < 0) {
11284
+ return false;
11285
+ }
11286
+ if (box2.bottom > (window.innerHeight || 0)) {
11287
+ return false;
11288
+ }
11289
+ return true;
11290
+ }
11277
11291
  const scrollAnchor = (formNode) => () => {
11292
+ if (formVisible(formNode)) {
11293
+ dbg("form is visible, not scrolling");
11294
+ return;
11295
+ }
11278
11296
  const anchorId = formNode.attrs.anchorElement || formNode.id;
11279
11297
  if (anchorId) {
11280
11298
  const anchor = document.getElementById(anchorId);
@@ -11302,7 +11320,7 @@ const fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
11302
11320
  }
11303
11321
  var step_values = null;
11304
11322
  try {
11305
- scrollAnchor(formNode)();
11323
+ setTimeout(scrollAnchor(formNode), 100);
11306
11324
  if (stepHistory2.value.length > 0) {
11307
11325
  step_values = flattenObj(formNode.value[stepHistory2.value[stepHistory2.value.length - 1]] || {});
11308
11326
  }