fix scroll
This commit is contained in:
committed by
Oleksandr Turchyn
parent
311c2b0e34
commit
f7a8e4102b
@@ -132,10 +132,18 @@ export default {
|
|||||||
this.scrollInContainer(areaRef.$el)
|
this.scrollInContainer(areaRef.$el)
|
||||||
} else {
|
} else {
|
||||||
const targetRect = areaRef.$refs.scrollToElem.getBoundingClientRect()
|
const targetRect = areaRef.$refs.scrollToElem.getBoundingClientRect()
|
||||||
const root = this.$root.$el?.parentNode?.classList?.contains('ds') ? this.$root.$el : document.body
|
|
||||||
const rootRect = root.getBoundingClientRect()
|
|
||||||
const scrollEl = this.scrollEl || window
|
const scrollEl = this.scrollEl || window
|
||||||
|
|
||||||
|
let rootRect = {}
|
||||||
|
|
||||||
|
if (this.scrollEl === document.documentElement) {
|
||||||
|
rootRect = this.scrollEl.getBoundingClientRect()
|
||||||
|
} else {
|
||||||
|
const root = this.$root.$el?.parentNode?.classList?.contains('ds') ? this.$root.$el : document.body
|
||||||
|
|
||||||
|
rootRect = root.getBoundingClientRect()
|
||||||
|
}
|
||||||
|
|
||||||
scrollEl.scrollTo({ top: targetRect.top - rootRect.top, behavior: 'smooth' })
|
scrollEl.scrollTo({ top: targetRect.top - rootRect.top, behavior: 'smooth' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user