@caweb/framework 1.9.17 → 1.9.18

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.
Files changed (74) hide show
  1. package/build/delta.asset.php +1 -1
  2. package/build/delta.js +65 -14
  3. package/build/delta.js.map +1 -1
  4. package/build/delta.min.asset.php +1 -1
  5. package/build/delta.min.js +1 -1
  6. package/build/delta.min.js.map +1 -1
  7. package/build/eureka.asset.php +1 -1
  8. package/build/eureka.js +65 -14
  9. package/build/eureka.js.map +1 -1
  10. package/build/eureka.min.asset.php +1 -1
  11. package/build/eureka.min.js +1 -1
  12. package/build/eureka.min.js.map +1 -1
  13. package/build/mono.asset.php +1 -1
  14. package/build/mono.js +65 -14
  15. package/build/mono.js.map +1 -1
  16. package/build/mono.min.asset.php +1 -1
  17. package/build/mono.min.js +1 -1
  18. package/build/mono.min.js.map +1 -1
  19. package/build/oceanside.asset.php +1 -1
  20. package/build/oceanside.js +65 -14
  21. package/build/oceanside.js.map +1 -1
  22. package/build/oceanside.min.asset.php +1 -1
  23. package/build/oceanside.min.js +1 -1
  24. package/build/oceanside.min.js.map +1 -1
  25. package/build/orangecounty.asset.php +1 -1
  26. package/build/orangecounty.js +65 -14
  27. package/build/orangecounty.js.map +1 -1
  28. package/build/orangecounty.min.asset.php +1 -1
  29. package/build/orangecounty.min.js +1 -1
  30. package/build/orangecounty.min.js.map +1 -1
  31. package/build/pasorobles.asset.php +1 -1
  32. package/build/pasorobles.js +65 -14
  33. package/build/pasorobles.js.map +1 -1
  34. package/build/pasorobles.min.asset.php +1 -1
  35. package/build/pasorobles.min.js +1 -1
  36. package/build/pasorobles.min.js.map +1 -1
  37. package/build/sacramento.asset.php +1 -1
  38. package/build/sacramento.js +65 -14
  39. package/build/sacramento.js.map +1 -1
  40. package/build/sacramento.min.asset.php +1 -1
  41. package/build/sacramento.min.js +1 -1
  42. package/build/sacramento.min.js.map +1 -1
  43. package/build/santabarbara.asset.php +1 -1
  44. package/build/santabarbara.js +65 -14
  45. package/build/santabarbara.js.map +1 -1
  46. package/build/santabarbara.min.asset.php +1 -1
  47. package/build/santabarbara.min.js +1 -1
  48. package/build/santabarbara.min.js.map +1 -1
  49. package/build/santacruz.asset.php +1 -1
  50. package/build/santacruz.js +65 -14
  51. package/build/santacruz.js.map +1 -1
  52. package/build/santacruz.min.asset.php +1 -1
  53. package/build/santacruz.min.js +1 -1
  54. package/build/santacruz.min.js.map +1 -1
  55. package/build/shasta.asset.php +1 -1
  56. package/build/shasta.js +65 -14
  57. package/build/shasta.js.map +1 -1
  58. package/build/shasta.min.asset.php +1 -1
  59. package/build/shasta.min.js +1 -1
  60. package/build/shasta.min.js.map +1 -1
  61. package/build/sierra.asset.php +1 -1
  62. package/build/sierra.js +65 -14
  63. package/build/sierra.js.map +1 -1
  64. package/build/sierra.min.asset.php +1 -1
  65. package/build/sierra.min.js +1 -1
  66. package/build/sierra.min.js.map +1 -1
  67. package/build/trinity.asset.php +1 -1
  68. package/build/trinity.js +65 -14
  69. package/build/trinity.js.map +1 -1
  70. package/build/trinity.min.asset.php +1 -1
  71. package/build/trinity.min.js +1 -1
  72. package/build/trinity.min.js.map +1 -1
  73. package/package.json +1 -1
  74. package/src/scripts/components/header.js +71 -14
@@ -1 +1 @@
1
- <?php return array('dependencies' => array(), 'version' => '1cbacd461f1a5bf57b84');
1
+ <?php return array('dependencies' => array(), 'version' => '776c2cb38e871f5d2155');
@@ -6372,23 +6372,76 @@ window.addEventListener('load', () => {
6372
6372
  return total;
6373
6373
  }, 0);
6374
6374
  };
6375
+
6376
+ // get the total height of all elements above the header with a fixed position.
6377
+ const getTopOffset = () => {
6378
+ let current = header;
6379
+ let offset = 0;
6380
+ while (current) {
6381
+ // if current element has a fixed position, add its height to the topOffset.
6382
+ if (current instanceof HTMLElement && window.getComputedStyle(current).position === 'fixed') {
6383
+ offset += current.clientHeight;
6384
+ }
6385
+ current = current.previousElementSibling;
6386
+ }
6387
+ return offset;
6388
+ };
6375
6389
  let compactedElementsHeight = getCompactedElementsHeight();
6390
+ let topOffset = getTopOffset();
6376
6391
 
6377
- // resize observer function to watch if compacted elements change height, so we can update the compacted elements height when they change.
6392
+ // resize observer function to watch if compacted elements were resized,
6393
+ // so we can update variables when they change.
6394
+ let observedElements = [];
6378
6395
  const clientHeightObserver = entries => {
6379
- for (const entry of entries) {
6380
- // update the compacted elements height when the compacted entry changes., which can happen when google translate loads and changes the height of the utility header or when items wrap
6396
+ let hasChanges = false;
6397
+
6398
+ // The callback receives an array of entries, one for each element that resized
6399
+ for (let entry of entries) {
6400
+ // we check if the entry was already saved once
6401
+ if (entry.target.dataset.observer) {
6402
+ let previousEntryIndex = observedElements.findIndex(observedEntry => observedEntry.target.dataset.observer === entry.target.dataset.observer);
6403
+ let previousEntry = observedElements[previousEntryIndex];
6404
+ let previousHeight = previousEntry instanceof ResizeObserverEntry ? previousEntry.contentBoxSize[0].blockSize : previousEntry.target.style.height;
6405
+ let currentHeight = entry instanceof ResizeObserverEntry ? entry.contentBoxSize[0].blockSize : entry.target.style.height;
6406
+
6407
+ // if the entry's height has changed, we set hasChanges to true, so we can update the compacted elements height and top offset.
6408
+ if (previousHeight !== currentHeight) {
6409
+ observedElements[previousEntryIndex] = entry;
6410
+ hasChanges = true;
6411
+ }
6412
+ } else {
6413
+ // if not, we save the entry in a data attribute, so we can identify it in future callbacks and avoid unnecessary calculations when an entry changes.
6414
+ entry.target.dataset.observer = crypto.randomUUID();
6415
+
6416
+ // save the entry
6417
+ observedElements.push(entry);
6418
+ }
6419
+ }
6420
+
6421
+ // if changes detected, we perform updates
6422
+ if (hasChanges) {
6423
+ topOffset = getTopOffset();
6381
6424
  compactedElementsHeight = getCompactedElementsHeight();
6425
+ updateScrollMarginTop();
6426
+ compactHeader();
6382
6427
  }
6383
6428
  };
6384
6429
 
6385
6430
  // observe compacted elements for height changes, so we can update the compacted elements height when they change.
6386
6431
  compactedElements.forEach(element => {
6387
6432
  if (element instanceof HTMLElement) {
6388
- const observer = new ResizeObserver(clientHeightObserver);
6389
- observer.observe(element);
6433
+ // we add a data-observer attribute to the element, so we can identify it in the callback and avoid unnecessary calculations when an entry changes.
6434
+ new ResizeObserver(clientHeightObserver).observe(element);
6390
6435
  }
6391
6436
  });
6437
+ let current = header;
6438
+ while (current) {
6439
+ // if current element has a fixed position add a resize observer
6440
+ if (current instanceof HTMLElement && window.getComputedStyle(current).position === 'fixed') {
6441
+ new ResizeObserver(clientHeightObserver).observe(current);
6442
+ }
6443
+ current = current.previousElementSibling;
6444
+ }
6392
6445
 
6393
6446
  // scroll to target
6394
6447
  if (location_hash) {
@@ -6411,12 +6464,12 @@ window.addEventListener('load', () => {
6411
6464
  // downscroll code passed the header height
6412
6465
  if (document.body.scrollTop >= header.offsetHeight || document.documentElement.scrollTop >= header.offsetHeight) {
6413
6466
  // move the header up to hide the compacted elements height, minus the top offset.
6414
- header.style.top = `-${compactedElementsHeight}px`;
6467
+ header.style.top = `-${compactedElementsHeight - topOffset}px`;
6415
6468
  } else {
6416
6469
  // reset header to initial position
6417
6470
  // we need to set the header's top to the offset.
6418
6471
  if (header) {
6419
- header.style.top = 0;
6472
+ header.style.top = `${topOffset}px`;
6420
6473
  }
6421
6474
  }
6422
6475
  };
@@ -6434,18 +6487,16 @@ window.addEventListener('load', () => {
6434
6487
  if (element.offsetTop > scrollMarginHeight + scrollMarginHeight / 2) {
6435
6488
  scrollMarginHeight -= compactedElementsHeight;
6436
6489
  }
6437
- element.style.scrollMarginTop = `${scrollMarginHeight}px`;
6490
+ element.style.scrollMarginTop = `${scrollMarginHeight + topOffset}px`;
6438
6491
  }
6439
6492
  });
6440
6493
  };
6441
6494
 
6442
- // if there are alerts add a mutation observer to watch for changes in the alerts container,
6495
+ // if there are alerts add a mutation observer to watch for changes in the alerts
6443
6496
  if (alerts) {
6444
- // so we can update the compacted elements height when an alert is closed or a new alert is added.
6445
- new MutationObserver((mutationList, observer) => {
6446
- compactedElementsHeight = getCompactedElementsHeight();
6447
- updateScrollMarginTop();
6448
- }).observe(alerts, {
6497
+ // so we can update the compacted elements height when an alert is closed or
6498
+ // when entering mobile ( class .d-none is added/removed).
6499
+ new MutationObserver(clientHeightObserver).observe(alerts, {
6449
6500
  attributes: true,
6450
6501
  childList: true
6451
6502
  });