Skip to content

Commit 4c65284

Browse files
shenjunjianzzcr
authored andcommitted
fix(site): fix scroll bugs
1 parent b611d79 commit 4c65284

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

examples/sites/src/views/components/components.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<span class="docs-header-spacer"></span>
1818
</header>
1919
<div class="docs-content" id="doc-layout-scoller">
20-
<div class="ti-fi-1 ti-rel cmp-container">
20+
<div class="ti-rel cmp-container">
2121
<div class="flex-horizontal docs-content-main">
2222
<div class="docs-tabs-wrap">
2323
<div v-if="['interfaces', 'types', 'classes'].includes(cmpId)" id="TS" class="all-api-container">
@@ -235,12 +235,10 @@
235235
<div class="cmp-page-anchor catalog" v-if="currAnchorLinks.length">
236236
<tiny-anchor
237237
id="anchor"
238-
:offset-top="156"
239238
:links="currAnchorLinks"
240239
:key="anchorRefreshKey"
241240
:is-affix="anchorAffix"
242241
type="dot"
243-
mask-class="custom-active-anchor"
244242
container-id="#doc-layout-scoller"
245243
@link-click="handleAnchorClick"
246244
>
@@ -486,8 +484,10 @@ export default defineComponent({
486484
scrollTarget = document.querySelector(`#${hash}`)
487485
} catch (err) {}
488486
if (scrollTarget && !isRunningTest) {
487+
// doc-layout-scoller(滚动) > tabs > tab-content(relative), 造成 scrollTarget.offsetTop 是相对于 tab-content的距离
488+
// 所以滚动需要修正 tab-title的占位高度才行
489489
document.getElementById('doc-layout-scoller').scrollTo({
490-
top: scrollTarget.offsetTop,
490+
top: scrollTarget.offsetTop + 52,
491491
left: 0,
492492
behavior: 'smooth'
493493
})
@@ -767,9 +767,6 @@ export default defineComponent({
767767

768768
<style lang="less" scoped>
769769
.docs-header {
770-
position: sticky;
771-
top: 0;
772-
z-index: var(--docs-header-zindex);
773770
padding: 16px 40px;
774771
background-color: #fff;
775772
box-shadow: 12px 0 20px 6px rgba(0, 0, 0, 0.06);

examples/sites/src/views/layout/layout.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,12 @@ export default defineComponent({
338338
}
339339
340340
#doc-layout {
341-
width: 100%;
342-
height: calc(100vh - 60px);
343-
flex-grow: 1;
344341
display: flex;
345342
flex-direction: column;
343+
flex-grow: 1;
344+
overflow: hidden auto;
345+
width: 100%;
346+
height: calc(100vh - 60px);
346347
}
347348
348349
.api-type-box {

0 commit comments

Comments
 (0)