@brandocms/jupiter 5.0.0-beta.16 → 5.0.0-beta.17
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/README.md
CHANGED
|
@@ -994,6 +994,8 @@ Same options as FixedHeader - see FixedHeader documentation below.
|
|
|
994
994
|
- `sections`
|
|
995
995
|
- Here you can set a config per section (body[data-script="section"])
|
|
996
996
|
- `unPinOnResize` - auto unpin while resizing
|
|
997
|
+
- `headerHeightTracksPin` - default `true`. Whether `--header-height` drops to `0px`
|
|
998
|
+
while the header is unpinned. Set `false` for a header that never retracts.
|
|
997
999
|
- `offset` - when is header triggered
|
|
998
1000
|
- `offsetBg` - when is offset background triggered (i.e. if there's another bg for content)
|
|
999
1001
|
- events are same as under default.
|
|
@@ -1034,6 +1036,22 @@ Same options as FixedHeader - see FixedHeader documentation below.
|
|
|
1034
1036
|
- `onMobileMenuClose`
|
|
1035
1037
|
- Triggers when mobile menu closes
|
|
1036
1038
|
|
|
1039
|
+
### CSS variables
|
|
1040
|
+
|
|
1041
|
+
`--header-height` is kept up to date on `:root`, republished whenever the header pins,
|
|
1042
|
+
unpins or toggles small/big. By default it is how much header is *visible* — the
|
|
1043
|
+
measured height while pinned, `0px` while unpinned — so anything positioned under the
|
|
1044
|
+
bar follows it out of the way as it retracts.
|
|
1045
|
+
|
|
1046
|
+
For a header that never retracts — through `preventUnpin`, or by no-opping
|
|
1047
|
+
`onPin`/`onUnpin` — set `headerHeightTracksPin: false`. The bar stays put, but the
|
|
1048
|
+
pinned state still flips on every change of scroll direction, so the variable would
|
|
1049
|
+
otherwise drop to `0px` and back while nothing moves. Any layout sized from it (a
|
|
1050
|
+
`padding-top` standing in for the fixed bar, say) then grows and shrinks the document
|
|
1051
|
+
under the reader. Scroll anchoring absorbs that mid-page, but not at the very bottom,
|
|
1052
|
+
where the scroll offset is clamped to the document and the page visibly jumps.
|
|
1053
|
+
`headerHeightTracksPin: false` publishes the measured height throughout.
|
|
1054
|
+
|
|
1037
1055
|
```
|
|
1038
1056
|
header[data-nav] {
|
|
1039
1057
|
@include container();
|
package/package.json
CHANGED
|
@@ -50,6 +50,7 @@ import { set } from '../../utils/motion-helpers'
|
|
|
50
50
|
/**
|
|
51
51
|
* @typedef {Object} FixedHeaderSectionOptions
|
|
52
52
|
* @property {boolean} [unPinOnResize=true] - Whether to unpin header on window resize
|
|
53
|
+
* @property {boolean} [headerHeightTracksPin=true] - Whether --header-height drops to 0 when the header unpins. Set false for a header that never retracts.
|
|
53
54
|
* @property {Window|HTMLElement} [canvas=window] - Scrolling element
|
|
54
55
|
* @property {string|null} [intersects=null] - Selector for elements to check intersection with
|
|
55
56
|
* @property {Function} [beforeEnter] - Called before header enters
|
|
@@ -153,6 +154,7 @@ const DEFAULT_OPTIONS = {
|
|
|
153
154
|
|
|
154
155
|
default: {
|
|
155
156
|
unPinOnResize: true,
|
|
157
|
+
headerHeightTracksPin: true,
|
|
156
158
|
canvas: window,
|
|
157
159
|
intersects: null,
|
|
158
160
|
beforeEnter: (h) => {
|
|
@@ -612,10 +614,25 @@ export default class FixedHeader {
|
|
|
612
614
|
|
|
613
615
|
/**
|
|
614
616
|
* Update the --header-height CSS variable on :root.
|
|
615
|
-
*
|
|
617
|
+
*
|
|
618
|
+
* By default this is how much header is *visible* — the measured height when
|
|
619
|
+
* pinned, 0 when unpinned — so anything positioned under the bar follows it
|
|
620
|
+
* out of the way as it retracts.
|
|
621
|
+
*
|
|
622
|
+
* That is wrong for a header configured never to retract, whether through
|
|
623
|
+
* `preventUnpin` or by no-opping `onPin` / `onUnpin`. The bar stays put, but
|
|
624
|
+
* `_pinned` still flips on every change of scroll direction, so the variable
|
|
625
|
+
* drops to 0 and back while nothing moves. Any layout sized from it — a
|
|
626
|
+
* `padding-top` standing in for the fixed bar, say — then grows and shrinks
|
|
627
|
+
* the document under the reader. Scroll anchoring absorbs that mid-page, but
|
|
628
|
+
* not at the very bottom, where the scroll offset is clamped to the document
|
|
629
|
+
* and the page visibly jumps instead.
|
|
630
|
+
*
|
|
631
|
+
* `headerHeightTracksPin: false` publishes the measured height throughout.
|
|
616
632
|
*/
|
|
617
633
|
_updateHeaderHeight() {
|
|
618
|
-
const
|
|
634
|
+
const tracksPin = this.opts.headerHeightTracksPin !== false
|
|
635
|
+
const height = tracksPin && !this._pinned ? '0px' : `${this.el.clientHeight}px`
|
|
619
636
|
document.documentElement.style.setProperty('--header-height', height)
|
|
620
637
|
}
|
|
621
638
|
|
|
@@ -15,6 +15,10 @@ export default class FixedHeader {
|
|
|
15
15
|
* - Whether to unpin header on window resize
|
|
16
16
|
*/
|
|
17
17
|
unPinOnResize?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* - Whether --header-height drops to 0 when the header unpins. Set false for a header that never retracts.
|
|
20
|
+
*/
|
|
21
|
+
headerHeightTracksPin?: boolean;
|
|
18
22
|
/**
|
|
19
23
|
* - Scrolling element
|
|
20
24
|
*/
|
|
@@ -110,7 +114,21 @@ export default class FixedHeader {
|
|
|
110
114
|
small(): void;
|
|
111
115
|
/**
|
|
112
116
|
* Update the --header-height CSS variable on :root.
|
|
113
|
-
*
|
|
117
|
+
*
|
|
118
|
+
* By default this is how much header is *visible* — the measured height when
|
|
119
|
+
* pinned, 0 when unpinned — so anything positioned under the bar follows it
|
|
120
|
+
* out of the way as it retracts.
|
|
121
|
+
*
|
|
122
|
+
* That is wrong for a header configured never to retract, whether through
|
|
123
|
+
* `preventUnpin` or by no-opping `onPin` / `onUnpin`. The bar stays put, but
|
|
124
|
+
* `_pinned` still flips on every change of scroll direction, so the variable
|
|
125
|
+
* drops to 0 and back while nothing moves. Any layout sized from it — a
|
|
126
|
+
* `padding-top` standing in for the fixed bar, say — then grows and shrinks
|
|
127
|
+
* the document under the reader. Scroll anchoring absorbs that mid-page, but
|
|
128
|
+
* not at the very bottom, where the scroll offset is clamped to the document
|
|
129
|
+
* and the page visibly jumps instead.
|
|
130
|
+
*
|
|
131
|
+
* `headerHeightTracksPin: false` publishes the measured height throughout.
|
|
114
132
|
*/
|
|
115
133
|
_updateHeaderHeight(): void;
|
|
116
134
|
notAltBg(): void;
|
|
@@ -200,6 +218,10 @@ export type FixedHeaderSectionOptions = {
|
|
|
200
218
|
* - Whether to unpin header on window resize
|
|
201
219
|
*/
|
|
202
220
|
unPinOnResize?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* - Whether --header-height drops to 0 when the header unpins. Set false for a header that never retracts.
|
|
223
|
+
*/
|
|
224
|
+
headerHeightTracksPin?: boolean;
|
|
203
225
|
/**
|
|
204
226
|
* - Scrolling element
|
|
205
227
|
*/
|