Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85712871
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/composables/useScrollPosition.js b/src/composables/useScrollPosition.js
index 1cf3373146..d32f6a261e 100644
--- a/src/composables/useScrollPosition.js
+++ b/src/composables/useScrollPosition.js
@@ -1,52 +1,49 @@
import { onMounted, onUnmounted, ref } from 'vue'
import { useWindowSize } from 'src/composables/useWindowSize.js'
export function useScrollPosition() {
const x = ref(0)
const y = ref(0)
const inProgress = ref(false)
const update = (e) => {
x.value = window.scrollX
y.value = window.scrollY
}
onMounted(() => {
window.addEventListener('scroll', update)
update()
})
onUnmounted(() => {
window.removeEventListener('scroll', update)
})
const scrollBy = async (x1, y1, options) => {
inProgress.value = true
await window.scrollBy(x1, y1, options)
inProgress.value = false
}
const scrollIntoView = async (element, options) => {
if (element == null) throw new TypeError(`Element is ${element}!`)
inProgress.value = true
- let call = element.scrollIntoViewIfNeeded
- if (!call) {
- call = (options) => {
- const { height: windowHeight } = useWindowSize()
- const { top, height } = element.getBoundingClientRect()
- const bottom = top + height
-
- const biggerThanScreen = height > windowHeight
- const aboveTop = top < 0
- const belowBottom = bottom > windowHeight.value
- if (aboveTop || belowBottom || biggerThanScreen) {
- element.scrollIntoView(options)
- }
+ if (!element.scrollIntoViewIfNeeded) {
+ const { height: windowHeight } = useWindowSize()
+ const { top, height } = element.getBoundingClientRect()
+ const bottom = top + height
+
+ const biggerThanScreen = height > windowHeight
+ const aboveTop = top < 0
+ const belowBottom = bottom > windowHeight.value
+ if (aboveTop || belowBottom || biggerThanScreen) {
+ await element.scrollIntoView(options)
}
}
- await call(options)
+ await element.scrollIntoViewIfNeeded(options)
inProgress.value = false
}
return { x, y, scrollBy, scrollIntoView, inProgress }
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Sep 19, 1:14 PM (20 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1763616
Default Alt Text
(2 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment