@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.
- package/build/delta.asset.php +1 -1
- package/build/delta.js +65 -14
- package/build/delta.js.map +1 -1
- package/build/delta.min.asset.php +1 -1
- package/build/delta.min.js +1 -1
- package/build/delta.min.js.map +1 -1
- package/build/eureka.asset.php +1 -1
- package/build/eureka.js +65 -14
- package/build/eureka.js.map +1 -1
- package/build/eureka.min.asset.php +1 -1
- package/build/eureka.min.js +1 -1
- package/build/eureka.min.js.map +1 -1
- package/build/mono.asset.php +1 -1
- package/build/mono.js +65 -14
- package/build/mono.js.map +1 -1
- package/build/mono.min.asset.php +1 -1
- package/build/mono.min.js +1 -1
- package/build/mono.min.js.map +1 -1
- package/build/oceanside.asset.php +1 -1
- package/build/oceanside.js +65 -14
- package/build/oceanside.js.map +1 -1
- package/build/oceanside.min.asset.php +1 -1
- package/build/oceanside.min.js +1 -1
- package/build/oceanside.min.js.map +1 -1
- package/build/orangecounty.asset.php +1 -1
- package/build/orangecounty.js +65 -14
- package/build/orangecounty.js.map +1 -1
- package/build/orangecounty.min.asset.php +1 -1
- package/build/orangecounty.min.js +1 -1
- package/build/orangecounty.min.js.map +1 -1
- package/build/pasorobles.asset.php +1 -1
- package/build/pasorobles.js +65 -14
- package/build/pasorobles.js.map +1 -1
- package/build/pasorobles.min.asset.php +1 -1
- package/build/pasorobles.min.js +1 -1
- package/build/pasorobles.min.js.map +1 -1
- package/build/sacramento.asset.php +1 -1
- package/build/sacramento.js +65 -14
- package/build/sacramento.js.map +1 -1
- package/build/sacramento.min.asset.php +1 -1
- package/build/sacramento.min.js +1 -1
- package/build/sacramento.min.js.map +1 -1
- package/build/santabarbara.asset.php +1 -1
- package/build/santabarbara.js +65 -14
- package/build/santabarbara.js.map +1 -1
- package/build/santabarbara.min.asset.php +1 -1
- package/build/santabarbara.min.js +1 -1
- package/build/santabarbara.min.js.map +1 -1
- package/build/santacruz.asset.php +1 -1
- package/build/santacruz.js +65 -14
- package/build/santacruz.js.map +1 -1
- package/build/santacruz.min.asset.php +1 -1
- package/build/santacruz.min.js +1 -1
- package/build/santacruz.min.js.map +1 -1
- package/build/shasta.asset.php +1 -1
- package/build/shasta.js +65 -14
- package/build/shasta.js.map +1 -1
- package/build/shasta.min.asset.php +1 -1
- package/build/shasta.min.js +1 -1
- package/build/shasta.min.js.map +1 -1
- package/build/sierra.asset.php +1 -1
- package/build/sierra.js +65 -14
- package/build/sierra.js.map +1 -1
- package/build/sierra.min.asset.php +1 -1
- package/build/sierra.min.js +1 -1
- package/build/sierra.min.js.map +1 -1
- package/build/trinity.asset.php +1 -1
- package/build/trinity.js +65 -14
- package/build/trinity.js.map +1 -1
- package/build/trinity.min.asset.php +1 -1
- package/build/trinity.min.js +1 -1
- package/build/trinity.min.js.map +1 -1
- package/package.json +1 -1
- package/src/scripts/components/header.js +71 -14
package/package.json
CHANGED
|
@@ -27,24 +27,83 @@ window.addEventListener('load', () => {
|
|
|
27
27
|
}, 0);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// get the total height of all elements above the header with a fixed position.
|
|
31
|
+
const getTopOffset = () => {
|
|
32
|
+
let current = header;
|
|
33
|
+
let offset = 0;
|
|
34
|
+
|
|
35
|
+
while( current ){
|
|
36
|
+
// if current element has a fixed position, add its height to the topOffset.
|
|
37
|
+
if( current instanceof HTMLElement && window.getComputedStyle(current).position === 'fixed' ){
|
|
38
|
+
offset += current.clientHeight ;
|
|
39
|
+
}
|
|
40
|
+
current = current.previousElementSibling;
|
|
41
|
+
}
|
|
42
|
+
return offset;
|
|
43
|
+
}
|
|
44
|
+
|
|
30
45
|
let compactedElementsHeight = getCompactedElementsHeight();
|
|
46
|
+
let topOffset = getTopOffset();
|
|
47
|
+
|
|
48
|
+
// resize observer function to watch if compacted elements were resized,
|
|
49
|
+
// so we can update variables when they change.
|
|
50
|
+
let observedElements = [];
|
|
31
51
|
|
|
32
|
-
// resize observer function to watch if compacted elements change height, so we can update the compacted elements height when they change.
|
|
33
52
|
const clientHeightObserver = (entries) => {
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
let hasChanges = false;
|
|
54
|
+
|
|
55
|
+
// The callback receives an array of entries, one for each element that resized
|
|
56
|
+
for (let entry of entries) {
|
|
57
|
+
// we check if the entry was already saved once
|
|
58
|
+
if( entry.target.dataset.observer ){
|
|
59
|
+
let previousEntryIndex = observedElements.findIndex( observedEntry => observedEntry.target.dataset.observer === entry.target.dataset.observer );
|
|
60
|
+
let previousEntry = observedElements[previousEntryIndex];
|
|
61
|
+
|
|
62
|
+
let previousHeight = previousEntry instanceof ResizeObserverEntry ? previousEntry.contentBoxSize[0].blockSize : previousEntry.target.style.height;
|
|
63
|
+
let currentHeight = entry instanceof ResizeObserverEntry ? entry.contentBoxSize[0].blockSize : entry.target.style.height;
|
|
64
|
+
|
|
65
|
+
// if the entry's height has changed, we set hasChanges to true, so we can update the compacted elements height and top offset.
|
|
66
|
+
if( previousHeight !== currentHeight ){
|
|
67
|
+
observedElements[previousEntryIndex] = entry;
|
|
68
|
+
hasChanges = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
} else {
|
|
72
|
+
// 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.
|
|
73
|
+
entry.target.dataset.observer = crypto.randomUUID();
|
|
74
|
+
|
|
75
|
+
// save the entry
|
|
76
|
+
observedElements.push(entry);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// if changes detected, we perform updates
|
|
81
|
+
if (hasChanges) {
|
|
82
|
+
topOffset = getTopOffset();
|
|
36
83
|
compactedElementsHeight = getCompactedElementsHeight();
|
|
84
|
+
|
|
85
|
+
updateScrollMarginTop();
|
|
86
|
+
compactHeader()
|
|
37
87
|
}
|
|
38
88
|
}
|
|
39
89
|
|
|
40
90
|
// observe compacted elements for height changes, so we can update the compacted elements height when they change.
|
|
41
91
|
compactedElements.forEach((element) => {
|
|
42
92
|
if( element instanceof HTMLElement ){
|
|
43
|
-
|
|
44
|
-
|
|
93
|
+
// 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.
|
|
94
|
+
new ResizeObserver(clientHeightObserver).observe(element);
|
|
45
95
|
}
|
|
46
96
|
});
|
|
47
97
|
|
|
98
|
+
let current = header;
|
|
99
|
+
while( current ){
|
|
100
|
+
// if current element has a fixed position add a resize observer
|
|
101
|
+
if( current instanceof HTMLElement && window.getComputedStyle(current).position === 'fixed' ){
|
|
102
|
+
new ResizeObserver(clientHeightObserver).observe(current);
|
|
103
|
+
}
|
|
104
|
+
current = current.previousElementSibling;
|
|
105
|
+
}
|
|
106
|
+
|
|
48
107
|
// scroll to target
|
|
49
108
|
if( location_hash ){
|
|
50
109
|
// location hash has leading #, so we remove it
|
|
@@ -69,13 +128,13 @@ window.addEventListener('load', () => {
|
|
|
69
128
|
document.documentElement.scrollTop >= header.offsetHeight
|
|
70
129
|
) {
|
|
71
130
|
// move the header up to hide the compacted elements height, minus the top offset.
|
|
72
|
-
header.style.top = `-${(compactedElementsHeight)}px`;
|
|
131
|
+
header.style.top = `-${(compactedElementsHeight - topOffset)}px`;
|
|
73
132
|
|
|
74
133
|
} else {
|
|
75
134
|
// reset header to initial position
|
|
76
135
|
// we need to set the header's top to the offset.
|
|
77
136
|
if( header ){
|
|
78
|
-
header.style.top =
|
|
137
|
+
header.style.top = `${topOffset}px`;
|
|
79
138
|
}
|
|
80
139
|
|
|
81
140
|
}
|
|
@@ -95,19 +154,17 @@ window.addEventListener('load', () => {
|
|
|
95
154
|
if( element.offsetTop > scrollMarginHeight + (scrollMarginHeight / 2) ){
|
|
96
155
|
scrollMarginHeight -= compactedElementsHeight;
|
|
97
156
|
}
|
|
98
|
-
element.style.scrollMarginTop = `${scrollMarginHeight}px`;
|
|
157
|
+
element.style.scrollMarginTop = `${scrollMarginHeight + topOffset}px`;
|
|
99
158
|
}
|
|
100
159
|
});
|
|
101
160
|
|
|
102
161
|
}
|
|
103
162
|
|
|
104
|
-
// if there are alerts add a mutation observer to watch for changes in the alerts
|
|
163
|
+
// if there are alerts add a mutation observer to watch for changes in the alerts
|
|
105
164
|
if( alerts ){
|
|
106
|
-
// so we can update the compacted elements height when an alert is closed or
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
updateScrollMarginTop();
|
|
110
|
-
}).observe(alerts, { attributes: true, childList: true });
|
|
165
|
+
// so we can update the compacted elements height when an alert is closed or
|
|
166
|
+
// when entering mobile ( class .d-none is added/removed).
|
|
167
|
+
new MutationObserver(clientHeightObserver).observe(alerts, { attributes: true, childList: true });
|
|
111
168
|
}
|
|
112
169
|
|
|
113
170
|
// add scroll event listener to compact the header on scroll
|