@brandocms/jupiter 5.0.0-beta.17 → 5.0.0-beta.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/README.md
CHANGED
|
@@ -949,6 +949,10 @@ when the original header is visible.
|
|
|
949
949
|
- Pin header when scroll is forced (`application.scrollTo`, clicking anchors etc)
|
|
950
950
|
- `unPinOnResize` - default `false`
|
|
951
951
|
- Unpin header when window is resized
|
|
952
|
+
- `headerHeightTracksPin` - default `true`
|
|
953
|
+
- Set per section (under `default` / `sections`). Whether `--header-height` drops
|
|
954
|
+
to `0px` while the header is unpinned. Set `false` for a header that never
|
|
955
|
+
retracts — see [CSS variables](#css-variables) under FixedHeader.
|
|
952
956
|
|
|
953
957
|
- Events
|
|
954
958
|
- `onMainVisible`
|
|
@@ -978,7 +982,8 @@ its space is still reserved.
|
|
|
978
982
|
|
|
979
983
|
### Options
|
|
980
984
|
|
|
981
|
-
Same options as FixedHeader - see FixedHeader documentation below
|
|
985
|
+
Same options as FixedHeader - see FixedHeader documentation below, including
|
|
986
|
+
`headerHeightTracksPin` and the [CSS variables](#css-variables) section.
|
|
982
987
|
|
|
983
988
|
|
|
984
989
|
## FixedHeader
|
package/package.json
CHANGED
|
@@ -80,6 +80,7 @@ const DEFAULT_OPTIONS = {
|
|
|
80
80
|
|
|
81
81
|
default: {
|
|
82
82
|
onClone: (h) => h.el.cloneNode(true),
|
|
83
|
+
headerHeightTracksPin: true,
|
|
83
84
|
canvas: window,
|
|
84
85
|
beforeEnter: (h) => {
|
|
85
86
|
set(h.el, { opacity: 0 })
|
|
@@ -450,11 +451,25 @@ export default class DoubleHeader {
|
|
|
450
451
|
|
|
451
452
|
/**
|
|
452
453
|
* Update the --header-height CSS variable on :root.
|
|
453
|
-
*
|
|
454
|
-
*
|
|
454
|
+
*
|
|
455
|
+
* Measured from `el`, the main header — `auxEl` is the clone. By default this
|
|
456
|
+
* is how much header is *visible*, the measured height when pinned and 0 when
|
|
457
|
+
* unpinned, so anything positioned under the bar follows it out of the way as
|
|
458
|
+
* the clone retracts.
|
|
459
|
+
*
|
|
460
|
+
* That is wrong for a header configured never to retract, whether through
|
|
461
|
+
* `preventUnpin` or by no-opping `onPin` / `onUnpin`. The bar stays put, but
|
|
462
|
+
* `_pinned` still flips on every change of scroll direction, so the variable
|
|
463
|
+
* drops to 0 and back while nothing moves. Any layout sized from it then grows
|
|
464
|
+
* and shrinks the document under the reader. Scroll anchoring absorbs that
|
|
465
|
+
* mid-page, but not at the very bottom, where the scroll offset is clamped to
|
|
466
|
+
* the document and the page visibly jumps instead.
|
|
467
|
+
*
|
|
468
|
+
* `headerHeightTracksPin: false` publishes the measured height throughout.
|
|
455
469
|
*/
|
|
456
470
|
_updateHeaderHeight() {
|
|
457
|
-
const
|
|
471
|
+
const tracksPin = this.opts.headerHeightTracksPin !== false
|
|
472
|
+
const height = tracksPin && !this._pinned ? '0px' : `${this.el.clientHeight}px`
|
|
458
473
|
document.documentElement.style.setProperty('--header-height', height)
|
|
459
474
|
}
|
|
460
475
|
|
|
@@ -52,6 +52,7 @@ import { set } from '../../utils/motion-helpers'
|
|
|
52
52
|
/**
|
|
53
53
|
* @typedef {Object} StickyHeaderSectionOptions
|
|
54
54
|
* @property {boolean} [unPinOnResize=true] - Whether to unpin header on window resize
|
|
55
|
+
* @property {boolean} [headerHeightTracksPin=true] - Whether --header-height drops to 0 when the header unpins. Set false for a header that never retracts.
|
|
55
56
|
* @property {Window|HTMLElement} [canvas=window] - Scrolling element
|
|
56
57
|
* @property {string|null} [intersects=null] - Selector for elements to check intersection with
|
|
57
58
|
* @property {Function} [beforeEnter] - Called before header enters
|
|
@@ -155,6 +156,7 @@ const DEFAULT_OPTIONS = {
|
|
|
155
156
|
|
|
156
157
|
default: {
|
|
157
158
|
unPinOnResize: true,
|
|
159
|
+
headerHeightTracksPin: true,
|
|
158
160
|
canvas: window,
|
|
159
161
|
intersects: null,
|
|
160
162
|
beforeEnter: (h) => {
|
|
@@ -609,10 +611,24 @@ export default class StickyHeader {
|
|
|
609
611
|
|
|
610
612
|
/**
|
|
611
613
|
* Update the --header-height CSS variable on :root.
|
|
612
|
-
*
|
|
614
|
+
*
|
|
615
|
+
* By default this is how much header is *visible* — the measured height when
|
|
616
|
+
* pinned, 0 when unpinned — so anything positioned under the bar follows it
|
|
617
|
+
* out of the way as it retracts.
|
|
618
|
+
*
|
|
619
|
+
* That is wrong for a header configured never to retract, whether through
|
|
620
|
+
* `preventUnpin` or by no-opping `onPin` / `onUnpin`. The bar stays put, but
|
|
621
|
+
* `_pinned` still flips on every change of scroll direction, so the variable
|
|
622
|
+
* drops to 0 and back while nothing moves. Any layout sized from it then grows
|
|
623
|
+
* and shrinks the document under the reader. Scroll anchoring absorbs that
|
|
624
|
+
* mid-page, but not at the very bottom, where the scroll offset is clamped to
|
|
625
|
+
* the document and the page visibly jumps instead.
|
|
626
|
+
*
|
|
627
|
+
* `headerHeightTracksPin: false` publishes the measured height throughout.
|
|
613
628
|
*/
|
|
614
629
|
_updateHeaderHeight() {
|
|
615
|
-
const
|
|
630
|
+
const tracksPin = this.opts.headerHeightTracksPin !== false
|
|
631
|
+
const height = tracksPin && !this._pinned ? '0px' : `${this.el.clientHeight}px`
|
|
616
632
|
document.documentElement.style.setProperty('--header-height', height)
|
|
617
633
|
}
|
|
618
634
|
|
|
@@ -48,8 +48,21 @@ export default class DoubleHeader {
|
|
|
48
48
|
small(): void;
|
|
49
49
|
/**
|
|
50
50
|
* Update the --header-height CSS variable on :root.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
*
|
|
52
|
+
* Measured from `el`, the main header — `auxEl` is the clone. By default this
|
|
53
|
+
* is how much header is *visible*, the measured height when pinned and 0 when
|
|
54
|
+
* unpinned, so anything positioned under the bar follows it out of the way as
|
|
55
|
+
* the clone retracts.
|
|
56
|
+
*
|
|
57
|
+
* That is wrong for a header configured never to retract, whether through
|
|
58
|
+
* `preventUnpin` or by no-opping `onPin` / `onUnpin`. The bar stays put, but
|
|
59
|
+
* `_pinned` still flips on every change of scroll direction, so the variable
|
|
60
|
+
* drops to 0 and back while nothing moves. Any layout sized from it then grows
|
|
61
|
+
* and shrinks the document under the reader. Scroll anchoring absorbs that
|
|
62
|
+
* mid-page, but not at the very bottom, where the scroll offset is clamped to
|
|
63
|
+
* the document and the page visibly jumps instead.
|
|
64
|
+
*
|
|
65
|
+
* `headerHeightTracksPin: false` publishes the measured height throughout.
|
|
53
66
|
*/
|
|
54
67
|
_updateHeaderHeight(): void;
|
|
55
68
|
shouldUnpin(toleranceExceeded: any): any;
|
|
@@ -59,7 +59,20 @@ export default class StickyHeader {
|
|
|
59
59
|
small(): void;
|
|
60
60
|
/**
|
|
61
61
|
* Update the --header-height CSS variable on :root.
|
|
62
|
-
*
|
|
62
|
+
*
|
|
63
|
+
* By default this is how much header is *visible* — the measured height when
|
|
64
|
+
* pinned, 0 when unpinned — so anything positioned under the bar follows it
|
|
65
|
+
* out of the way as it retracts.
|
|
66
|
+
*
|
|
67
|
+
* That is wrong for a header configured never to retract, whether through
|
|
68
|
+
* `preventUnpin` or by no-opping `onPin` / `onUnpin`. The bar stays put, but
|
|
69
|
+
* `_pinned` still flips on every change of scroll direction, so the variable
|
|
70
|
+
* drops to 0 and back while nothing moves. Any layout sized from it then grows
|
|
71
|
+
* and shrinks the document under the reader. Scroll anchoring absorbs that
|
|
72
|
+
* mid-page, but not at the very bottom, where the scroll offset is clamped to
|
|
73
|
+
* the document and the page visibly jumps instead.
|
|
74
|
+
*
|
|
75
|
+
* `headerHeightTracksPin: false` publishes the measured height throughout.
|
|
63
76
|
*/
|
|
64
77
|
_updateHeaderHeight(): void;
|
|
65
78
|
notAltBg(): void;
|
|
@@ -143,6 +156,10 @@ export type StickyHeaderSectionOptions = {
|
|
|
143
156
|
* - Whether to unpin header on window resize
|
|
144
157
|
*/
|
|
145
158
|
unPinOnResize?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* - Whether --header-height drops to 0 when the header unpins. Set false for a header that never retracts.
|
|
161
|
+
*/
|
|
162
|
+
headerHeightTracksPin?: boolean;
|
|
146
163
|
/**
|
|
147
164
|
* - Scrolling element
|
|
148
165
|
*/
|