11// Adopted from Vector 2022
22const
33 scrollObserver = require ( './scrollObserver.js' ) ,
4- resizeObserver = require ( './resizeObserver.js' ) ,
54 initSectionObserver = require ( './sectionObserver.js' ) ,
65 stickyHeader = require ( './stickyHeader.js' ) ,
76 initTableOfContents = require ( './tableOfContents.js' ) ,
@@ -187,13 +186,11 @@ const main = () => {
187186
188187 const
189188 stickyHeaderElement = document . getElementById ( stickyHeader . STICKY_HEADER_ID ) ,
190- stickyIntersection = document . getElementById ( 'citizen-page-header-sticky-sentinel' ) ,
191- stickyPlaceholder = document . getElementById ( stickyHeader . STICKY_HEADER_PLACEHOLDER_ID ) ;
189+ stickyIntersection = document . getElementById ( 'citizen-page-header-sticky-sentinel' ) ;
192190
193191 // eslint-disable-next-line es-x/no-optional-chaining
194192 const shouldStickyHeader = getComputedStyle ( stickyIntersection ) ?. getPropertyValue ( 'display' ) !== 'none' ;
195193 const isStickyHeaderAllowed = ! ! stickyHeaderElement &&
196- ! ! stickyPlaceholder &&
197194 ! ! stickyIntersection &&
198195 shouldStickyHeader ;
199196
@@ -209,13 +206,17 @@ const main = () => {
209206 10
210207 ) ;
211208
209+ if ( isStickyHeaderAllowed ) {
210+ stickyHeader . init ( stickyHeaderElement ) ;
211+ }
212+
212213 const resumeStickyHeader = ( ) => {
213214 if (
214215 isStickyHeaderAllowed &&
215216 ! document . body . classList . contains ( stickyHeader . STICKY_HEADER_VISIBLE_CLASS ) &&
216217 document . body . classList . contains ( PAGE_TITLE_INTERSECTION_CLASS )
217218 ) {
218- stickyHeader . show ( stickyHeaderElement , stickyPlaceholder ) ;
219+ stickyHeader . show ( stickyHeaderElement ) ;
219220 if ( document . documentElement . classList . contains ( 'citizen-feature-autohide-navigation-clientpref-1' ) ) {
220221 scrollDirectionObserver . resume ( ) ;
221222 }
@@ -224,7 +225,7 @@ const main = () => {
224225
225226 const pauseStickyHeader = ( ) => {
226227 if ( document . body . classList . contains ( stickyHeader . STICKY_HEADER_VISIBLE_CLASS ) ) {
227- stickyHeader . hide ( stickyHeaderElement , stickyPlaceholder ) ;
228+ stickyHeader . hide ( stickyHeaderElement ) ;
228229 scrollDirectionObserver . pause ( ) ;
229230 }
230231 } ;
@@ -242,39 +243,6 @@ const main = () => {
242243
243244 pageHeaderObserver . observe ( stickyIntersection ) ;
244245
245- // Initialize var
246- let bodyWidth = 0 ;
247- const bodyObserver = resizeObserver . initResizeObserver (
248- // onResize
249- ( ) => { } ,
250- // onResizeStart
251- ( entry ) => {
252- // eslint-disable-next-line es-x/no-optional-chaining
253- bodyWidth = entry . borderBoxSize ?. [ 0 ] . inlineSize ;
254- // Disable all CSS animation during resize
255- if ( document . documentElement . classList . contains ( 'citizen-animations-ready' ) ) {
256- document . documentElement . classList . remove ( 'citizen-animations-ready' ) ;
257- }
258- } ,
259- // onResizeEnd
260- ( entry ) => {
261- // eslint-disable-next-line es-x/no-optional-chaining
262- const newBodyWidth = entry . borderBoxSize ?. [ 0 ] . inlineSize ;
263- const shouldRecalcStickyHeader =
264- document . body . classList . contains ( PAGE_TITLE_INTERSECTION_CLASS ) &&
265- typeof newBodyWidth === 'number' &&
266- bodyWidth !== newBodyWidth ;
267-
268- // Enable CSS animation after resize is finished
269- document . documentElement . classList . add ( 'citizen-animations-ready' ) ;
270- // Recalculate sticky header height at the end of the resize
271- if ( shouldRecalcStickyHeader ) {
272- resumeStickyHeader ( ) ;
273- }
274- }
275- ) ;
276- bodyObserver . observe ( document . body ) ;
277-
278246 mw . hook ( 've.activationStart' ) . add ( ( ) => {
279247 pauseStickyHeader ( ) ;
280248 } ) ;
0 commit comments