From 49b43eb3c829fe10ea09e2c78fd774bfd99e0419 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Oct 2021 14:47:52 +0900 Subject: [PATCH] :art: --- src/client/components/global/header.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/components/global/header.vue b/src/client/components/global/header.vue index 977912e2bd..7953d8a6d6 100644 --- a/src/client/components/global/header.vue +++ b/src/client/components/global/header.vue @@ -91,11 +91,15 @@ export default defineComponent({ bg.setAlpha(0.85); this.bg = bg.toRgbString(); - if (this.$el.parentElement == null) return; - this.narrow = this.$el.parentElement.offsetWidth < 500; - new ResizeObserver((entries, observer) => { + if (this.$el.parentElement) { this.narrow = this.$el.parentElement.offsetWidth < 500; - }).observe(this.$el.parentElement); + new ResizeObserver((entries, observer) => { + this.narrow = this.$el.parentElement.offsetWidth < 500; + }).observe(this.$el.parentElement); + const currentStickyTop = getComputedStyle(this.$el).getPropertyValue('--stickyTop') || '0px'; + this.$el.style.setProperty('--stickyTop', currentStickyTop); + this.$el.parentElement.style.setProperty('--stickyTop', `calc(${currentStickyTop} + ${this.$el.offsetHeight}px)`); + } }, methods: {