This commit is contained in:
@@ -5,11 +5,15 @@ import SiteOptions from './site_options/SiteOptions.vue';
|
||||
import { ref, onMounted, onUnmounted } from 'vue';
|
||||
|
||||
const SCROLL_THRESHOLD = 120; // px scrolled before sticky header appears
|
||||
|
||||
const props = defineProps({
|
||||
alwaysVisible: { type: Boolean, default: false }
|
||||
});
|
||||
|
||||
const isVisible = ref(false);
|
||||
const isVisible = ref(props.alwaysVisible);
|
||||
|
||||
function onScroll() {
|
||||
isVisible.value = window.scrollY > SCROLL_THRESHOLD;
|
||||
isVisible.value = props.alwaysVisible || window.scrollY > SCROLL_THRESHOLD;
|
||||
}
|
||||
|
||||
onMounted(() => window.addEventListener('scroll', onScroll, { passive: true }));
|
||||
|
||||
Reference in New Issue
Block a user