@brandocms/jupiter 5.0.0-beta.16 → 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 +24 -1
- package/package.json +1 -1
- package/src/modules/DoubleHeader/index.js +18 -3
- package/src/modules/FixedHeader/index.js +19 -2
- package/src/modules/StickyHeader/index.js +18 -2
- package/types/modules/DoubleHeader/index.d.ts +15 -2
- package/types/modules/FixedHeader/index.d.ts +23 -1
- package/types/modules/StickyHeader/index.d.ts +18 -1
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
|
|
@@ -994,6 +999,8 @@ Same options as FixedHeader - see FixedHeader documentation below.
|
|
|
994
999
|
- `sections`
|
|
995
1000
|
- Here you can set a config per section (body[data-script="section"])
|
|
996
1001
|
- `unPinOnResize` - auto unpin while resizing
|
|
1002
|
+
- `headerHeightTracksPin` - default `true`. Whether `--header-height` drops to `0px`
|
|
1003
|
+
while the header is unpinned. Set `false` for a header that never retracts.
|
|
997
1004
|
- `offset` - when is header triggered
|
|
998
1005
|
- `offsetBg` - when is offset background triggered (i.e. if there's another bg for content)
|
|
999
1006
|
- events are same as under default.
|
|
@@ -1034,6 +1041,22 @@ Same options as FixedHeader - see FixedHeader documentation below.
|
|
|
1034
1041
|
- `onMobileMenuClose`
|
|
1035
1042
|
- Triggers when mobile menu closes
|
|
1036
1043
|
|
|
1044
|
+
### CSS variables
|
|
1045
|
+
|
|
1046
|
+
`--header-height` is kept up to date on `:root`, republished whenever the header pins,
|
|
1047
|
+
unpins or toggles small/big. By default it is how much header is *visible* — the
|
|
1048
|
+
measured height while pinned, `0px` while unpinned — so anything positioned under the
|
|
1049
|
+
bar follows it out of the way as it retracts.
|
|
1050
|
+
|
|
1051
|
+
For a header that never retracts — through `preventUnpin`, or by no-opping
|
|
1052
|
+
`onPin`/`onUnpin` — set `headerHeightTracksPin: false`. The bar stays put, but the
|
|
1053
|
+
pinned state still flips on every change of scroll direction, so the variable would
|
|
1054
|
+
otherwise drop to `0px` and back while nothing moves. Any layout sized from it (a
|
|
1055
|
+
`padding-top` standing in for the fixed bar, say) then grows and shrinks the document
|
|
1056
|
+
under the reader. Scroll anchoring absorbs that mid-page, but not at the very bottom,
|
|
1057
|
+
where the scroll offset is clamped to the document and the page visibly jumps.
|
|
1058
|
+
`headerHeightTracksPin: false` publishes the measured height throughout.
|
|
1059
|
+
|
|
1037
1060
|
```
|
|
1038
1061
|
header[data-nav] {
|
|
1039
1062
|
@include container();
|
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
|
|
|
@@ -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
|
|
|
@@ -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;
|
|
@@ -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
|
*/
|
|
@@ -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
|
*/
|