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.
@@ -18069,7 +18069,25 @@ function getCoords(elem) {
18069
18069
  left: box2.left + window.pageXOffset
18070
18070
  };
18071
18071
  }
18072
+ function formVisible(formNode) {
18073
+ var form2 = document.getElementById(formNode.id);
18074
+ if (!form2) {
18075
+ return false;
18076
+ }
18077
+ var box2 = form2.getBoundingClientRect();
18078
+ if (box2.top < 0) {
18079
+ return false;
18080
+ }
18081
+ if (box2.bottom > (window.innerHeight || 0)) {
18082
+ return false;
18083
+ }
18084
+ return true;
18085
+ }
18072
18086
  var scrollAnchor = (formNode) => () => {
18087
+ if (formVisible(formNode)) {
18088
+ dbg("form is visible, not scrolling");
18089
+ return;
18090
+ }
18073
18091
  var anchorId = formNode.attrs.anchorElement || formNode.id;
18074
18092
  if (anchorId) {
18075
18093
  var anchor = document.getElementById(anchorId);
@@ -18097,7 +18115,7 @@ var fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
18097
18115
  }
18098
18116
  var step_values = null;
18099
18117
  try {
18100
- scrollAnchor(formNode)();
18118
+ setTimeout(scrollAnchor(formNode), 100);
18101
18119
  if (stepHistory2.value.length > 0) {
18102
18120
  step_values = flattenObj(formNode.value[stepHistory2.value[stepHistory2.value.length - 1]] || {});
18103
18121
  }