This repository was archived by the owner on Feb 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -115,17 +115,29 @@ mode.subscribe((m) => {
115115
116116// Get a floating button element.
117117const floatingButtonEl = document . querySelector ( '.floating-button' )
118+ const topBarEl = document . querySelector ( '.top-bar' )
119+ let showingFloatingButton = false
118120
119121// Show this floating button when the user scrolls down.
120122window . addEventListener (
121123 'scroll' ,
122124 ( ) => {
123125 if ( window . scrollY > 200 ) {
124- floatingButtonEl . classList . remove ( 'opacity-0' )
125- floatingButtonEl . classList . add ( 'opacity-100' )
126+ if ( ! showingFloatingButton ) {
127+ floatingButtonEl . classList . remove ( 'opacity-0' )
128+ floatingButtonEl . classList . add ( 'opacity-100' )
129+ topBarEl . classList . remove ( 'pointer-events-none' )
130+ topBarEl . classList . add ( 'pointer-events-auto' )
131+ showingFloatingButton = true
132+ }
126133 } else {
127- floatingButtonEl . classList . add ( 'opacity-0' )
128- floatingButtonEl . classList . remove ( 'opacity-100' )
134+ if ( showingFloatingButton ) {
135+ floatingButtonEl . classList . add ( 'opacity-0' )
136+ floatingButtonEl . classList . remove ( 'opacity-100' )
137+ topBarEl . classList . add ( 'pointer-events-none' )
138+ topBarEl . classList . remove ( 'pointer-events-auto' )
139+ showingFloatingButton = false
140+ }
129141 }
130142 } ,
131143 { passive : true } ,
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ html(data-pdm="light dark blue" lang="en")
2121 include ./index.css
2222 body
2323 - var outline = [' focus:outline-none focus:shadow-outline focus:border-yellow-300' ]
24- div.container.fixed.top-0.right-0.left-0.flex.flew-row.px-3.mt-3 ( class ="md:mt-6" )
24+ div.container.fixed.top-0.right-0.left-0.flex.flew-row.px-3.mt-3.pointer-events-none.top-bar ( class ="md:mt-6" )
2525 button.rounded-sm.pdm-cycle.ml-auto.floating-button.opacity-0.transition-opacity.duration-300.ease-in-out ( style ="visibility: hidden;" class =outline)
2626 i.emoji.light.pdm-emoji
2727 div.container.px-3.mb-3
You can’t perform that action at this time.
0 commit comments