@brandocms/jupiter 5.0.0-beta.10 → 5.0.0-beta.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandocms/jupiter",
3
- "version": "5.0.0-beta.10",
3
+ "version": "5.0.0-beta.11",
4
4
  "description": "Frontend helpers.",
5
5
  "author": "Univers/Twined",
6
6
  "license": "UNLICENSED",
@@ -44,13 +44,13 @@
44
44
  "types": "types/index.d.ts",
45
45
  "dependencies": {
46
46
  "lodash.defaultsdeep": "^4.6.1",
47
- "motion": "^12.35.1"
47
+ "motion": "^12.35.2"
48
48
  },
49
49
  "devDependencies": {
50
- "@playwright/test": "^1.57.0",
51
- "@types/node": "^22.19.3",
50
+ "@playwright/test": "^1.58.2",
51
+ "@types/node": "^22",
52
52
  "typescript": "^5.9.3",
53
- "vite": "^6.4.1"
53
+ "vite": "^7.3.1"
54
54
  },
55
55
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
56
56
  }
@@ -202,6 +202,12 @@ export default class FixedHeader {
202
202
  */
203
203
  constructor(app, opts = {}) {
204
204
  this.app = app
205
+ // Preserve raw section configs before _defaultsDeep mutates them
206
+ this._rawSections = opts.sections
207
+ ? Object.fromEntries(
208
+ Object.entries(opts.sections).map(([k, v]) => [k, { ...v }])
209
+ )
210
+ : {}
205
211
  this.mainOpts = _defaultsDeep(opts, DEFAULT_OPTIONS)
206
212
 
207
213
  if (typeof this.mainOpts.el === 'string') {
@@ -704,6 +710,59 @@ export default class FixedHeader {
704
710
  )
705
711
  }
706
712
 
713
+ /**
714
+ * Reconfigure the header for a new section/page.
715
+ * Call this after a view transition or SPA navigation
716
+ * to re-resolve section options and reset scroll state.
717
+ */
718
+ reconfigure() {
719
+ const section = document.body.getAttribute('data-script')
720
+
721
+ // Build a fresh opts object from raw sections so function
722
+ // offsets that were previously resolved to numbers are restored
723
+ const freshOpts = {
724
+ ...this.mainOpts,
725
+ sections: Object.fromEntries(
726
+ Object.entries(this._rawSections).map(([k, v]) => [k, { ...v }])
727
+ )
728
+ }
729
+ this.opts = this._getOptionsForSection(section, freshOpts)
730
+
731
+ // Re-resolve dynamic offsets
732
+ if (typeof this.opts.offsetBg === 'string') {
733
+ const offsetBgElm = document.querySelector(this.opts.offsetBg)
734
+ this.opts.offsetBg = offsetBgElm ? offsetBgElm.offsetTop : 200
735
+ } else if (typeof this.opts.offsetBg === 'function') {
736
+ this.opts.offsetBg = this.opts.offsetBg(this) - 1
737
+ }
738
+
739
+ if (typeof this.opts.offset === 'string') {
740
+ const offsetElm = document.querySelector(this.opts.offset)
741
+ this.opts.offset = offsetElm ? offsetElm.offsetTop - 1 : 0
742
+ } else if (typeof this.opts.offset === 'function') {
743
+ this.opts.offset = this.opts.offset(this) - 1
744
+ }
745
+
746
+ if (typeof this.opts.offsetSmall === 'string') {
747
+ const offsetSmallElm = document.querySelector(this.opts.offsetSmall)
748
+ this.opts.offsetSmall = offsetSmallElm ? offsetSmallElm.offsetTop - 1 : 50
749
+ } else if (typeof this.opts.offsetSmall === 'function') {
750
+ this.opts.offsetSmall = this.opts.offsetSmall(this) - 1
751
+ }
752
+
753
+ // Reset scroll tracking to prevent the scroll-height-change
754
+ // guard from bailing out after content swap
755
+ this.lastKnownScrollY = this.getScrollY()
756
+ this.lastKnownScrollHeight = document.body.scrollHeight
757
+ this.currentScrollY = this.lastKnownScrollY
758
+ this.currentScrollHeight = this.lastKnownScrollHeight
759
+
760
+ // Re-check current state
761
+ this.checkSize(true)
762
+ this.checkBg(true)
763
+ this.checkTop(true)
764
+ }
765
+
707
766
  _getOptionsForSection(section, opts) {
708
767
  // if section is not a key in opts, return default opts
709
768
  if (