Skip to content

Commit

Permalink
fix(site): fix Popper layers separate when scrolling through document
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjunjian authored and zzcr committed Nov 8, 2024
1 parent 8eb46c5 commit 230d9be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
28 changes: 13 additions & 15 deletions examples/sites/src/views/components/components.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<span class="docs-header-spacer"></span>
</header>
<div class="docs-content">
<div class="docs-content" id="doc-layout-scoller">
<div class="ti-fi-1 ti-rel cmp-container">
<div class="flex-horizontal docs-content-main">
<div class="docs-tabs-wrap">
Expand Down Expand Up @@ -241,7 +241,7 @@
:is-affix="anchorAffix"
type="dot"
mask-class="custom-active-anchor"
container-id="#doc-layout"
container-id="#doc-layout-scoller"
@link-click="handleAnchorClick"
>
</tiny-anchor>
Expand All @@ -254,8 +254,8 @@
{{ i18nByKey('doc-owner') }} : {{ currJson.owner }}
</div>
</div>
<div id="footer"></div>
</div>
<div id="footer"></div>
</template>

<script lang="jsx">
Expand Down Expand Up @@ -473,7 +473,7 @@ export default defineComponent({
const scrollByHash = (hash) => {
setTimeout(() => {
if (!hash) {
document.getElementById('doc-layout').scrollTo({
document.getElementById('doc-layout-scoller').scrollTo({
top: 0,
left: 0
})
Expand All @@ -486,7 +486,7 @@ export default defineComponent({
scrollTarget = document.querySelector(`#${hash}`)
} catch (err) {}
if (scrollTarget && !isRunningTest) {
document.getElementById('doc-layout').scrollTo({
document.getElementById('doc-layout-scoller').scrollTo({
top: scrollTarget.offsetTop,
left: 0,
behavior: 'smooth'
Expand All @@ -501,7 +501,7 @@ export default defineComponent({
let hash = router.currentRoute.value.hash?.slice(1)
if (hash !== 'API') {
setTimeout(() => {
document.getElementById('doc-layout').scrollTo({
document.getElementById('doc-layout-scoller').scrollTo({
top: 0,
left: 0,
behavior: 'smooth'
Expand Down Expand Up @@ -622,26 +622,26 @@ export default defineComponent({
}
const onDocLayoutScroll = debounce(100, false, () => {
const docLayout = document.getElementById('doc-layout')
const docLayout = document.getElementById('doc-layout-scoller')
const { scrollTop, scrollHeight, clientHeight: layoutHeight } = docLayout
const headerHeight = document.querySelector('.docs-header')?.clientHeight || 0
const footerHeight = document.getElementById('footer')?.clientHeight || 0
const anchorHeight = document.querySelector('#anchor')?.clientHeight || 0
const remainHeight = scrollHeight - scrollTop - layoutHeight // doc-layout视口下隐藏的部分高度
const remainHeight = scrollHeight - scrollTop - layoutHeight // doc-layout-scoller视口下隐藏的部分高度
state.anchorAffix = layoutHeight - headerHeight - (footerHeight - remainHeight) > anchorHeight
})
const setScrollListener = () => {
nextTick(() => {
const docLayout = document.getElementById('doc-layout')
const docLayout = document.getElementById('doc-layout-scoller')
if (docLayout) {
docLayout.addEventListener('scroll', onDocLayoutScroll)
}
})
}
const removeScrollListener = () => {
const docLayout = document.getElementById('doc-layout')
const docLayout = document.getElementById('doc-layout-scoller')
if (docLayout) {
docLayout.removeEventListener('scroll', onDocLayoutScroll)
}
Expand Down Expand Up @@ -809,7 +809,9 @@ export default defineComponent({
}
.docs-content {
margin: 16px 0 120px;
flex: 1;
overflow: hidden auto;
padding: 16px 0 0;
transition: all ease-in-out 0.3s;
.docs-tabs-wrap {
Expand Down Expand Up @@ -972,10 +974,6 @@ export default defineComponent({
column-gap: 16px;
}
.docs-content-main {
overflow: auto;
}
.cmp-container {
p {
font-size: 16px;
Expand Down
1 change: 0 additions & 1 deletion examples/sites/src/views/layout/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ export default defineComponent({
#doc-layout {
width: 100%;
height: calc(100vh - 60px);
overflow: hidden auto;
flex-grow: 1;
display: flex;
flex-direction: column;
Expand Down

0 comments on commit 230d9be

Please sign in to comment.