优化滚动

pull/930/merge
lyswhut 2022-04-07 09:54:06 +08:00
parent 6de84d3b9b
commit 2e5adeb50c
4 changed files with 21 additions and 17 deletions

View File

@ -35,7 +35,6 @@ div.comment(:class="$style.comment" ref="dom_container")
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { scrollTo } from '@renderer/utils'
import music from '@renderer/utils/music' import music from '@renderer/utils/music'
import CommentFloor from './CommentFloor' import CommentFloor from './CommentFloor'
@ -170,7 +169,7 @@ export default {
this.newComment.page = page this.newComment.page = page
this.newComment.list = comment.comments this.newComment.list = comment.comments
this.$nextTick(() => { this.$nextTick(() => {
scrollTo(this.$refs.dom_commentNew, 0, 300) this.$refs.dom_commentNew.scrollTo(0, 0)
}) })
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
@ -189,7 +188,7 @@ export default {
this.hotComment.page = page this.hotComment.page = page
this.hotComment.list = hotComment.comments this.hotComment.list = hotComment.comments
this.$nextTick(() => { this.$nextTick(() => {
scrollTo(this.$refs.dom_commentHot, 0, 300) this.$refs.dom_commentHot.scrollTo(0, 0)
}) })
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
@ -321,6 +320,7 @@ export default {
height: 100%; height: 100%;
padding-left: 15px; padding-left: 15px;
padding-right: 10px; padding-right: 10px;
scroll-behavior: smooth;
} }
.commentLabel { .commentLabel {
padding: 15px; padding: 15px;

View File

@ -66,7 +66,7 @@ div(:class="$style.search")
<script> <script>
import { mapGetters, mapActions, mapMutations } from 'vuex' import { mapGetters, mapActions, mapMutations } from 'vuex'
import { scrollTo, clipboardWriteText, assertApiSupport, openUrl } from '@renderer/utils' import { clipboardWriteText, assertApiSupport, openUrl } from '@renderer/utils'
import musicSdk from '@renderer/utils/music' import musicSdk from '@renderer/utils/music'
import { defaultList } from '@renderer/core/share/list' import { defaultList } from '@renderer/core/share/list'
import { getList } from '@renderer/core/share/utils' import { getList } from '@renderer/core/share/utils'
@ -264,7 +264,7 @@ export default {
this.search({ text, page, limit: this.listInfo.limit }).then(data => { this.search({ text, page, limit: this.listInfo.limit }).then(data => {
this.page = page this.page = page
this.$nextTick(() => { this.$nextTick(() => {
scrollTo(this.$refs.dom_scrollContent, 0) this.$refs.dom_scrollContent.scrollTo(0, 0)
}) })
}).finally(() => { }).finally(() => {
this.isLoading = false this.isLoading = false
@ -569,6 +569,8 @@ export default {
.tbody { .tbody {
flex: auto; flex: auto;
overflow-y: auto; overflow-y: auto;
scroll-behavior: smooth;
td { td {
font-size: 12px; font-size: 12px;
:global(.badge) { :global(.badge) {

View File

@ -26,8 +26,7 @@ teleport(to="#view")
</template> </template>
<script> <script>
import { clipboardReadText, debounce, scrollTo } from '@renderer/utils' import { clipboardReadText, debounce } from '@renderer/utils'
let canceleFn
// https://blog.csdn.net/xcxy2015/article/details/77164126#comments // https://blog.csdn.net/xcxy2015/article/details/77164126#comments
@ -223,13 +222,13 @@ export default {
let dom = this.$refs.dom_list.children[this.selectIndex] let dom = this.$refs.dom_list.children[this.selectIndex]
let offsetTop = dom.offsetTop let offsetTop = dom.offsetTop
let scrollTop = this.$refs.dom_scrollContainer.scrollTop let scrollTop = this.$refs.dom_scrollContainer.scrollTop
let top
if (offsetTop < scrollTop) { if (offsetTop < scrollTop) {
if (canceleFn) canceleFn() top = offsetTop
canceleFn = scrollTo(this.$refs.dom_scrollContainer, offsetTop, 200, () => canceleFn = null)
} else if (offsetTop + dom.clientHeight > this.$refs.dom_scrollContainer.clientHeight + scrollTop) { } else if (offsetTop + dom.clientHeight > this.$refs.dom_scrollContainer.clientHeight + scrollTop) {
if (canceleFn) canceleFn() top = offsetTop + dom.clientHeight - this.$refs.dom_scrollContainer.clientHeight
canceleFn = scrollTo(this.$refs.dom_scrollContainer, offsetTop + dom.clientHeight - this.$refs.dom_scrollContainer.clientHeight, 200, () => canceleFn = null) } else return
} this.$refs.dom_scrollContainer.scrollTo(0, top)
}, },
handleContextMenu() { handleContextMenu() {
let str = clipboardReadText() let str = clipboardReadText()
@ -345,6 +344,8 @@ export default {
height: 0; height: 0;
transition-property: height; transition-property: height;
position: relative; position: relative;
scroll-behavior: smooth;
li { li {
position: relative; position: relative;
cursor: pointer; cursor: pointer;

View File

@ -56,7 +56,6 @@ div(:class="$style.container")
<script> <script>
import { mapGetters, mapMutations, mapActions } from 'vuex' import { mapGetters, mapMutations, mapActions } from 'vuex'
import { scrollTo } from '@renderer/utils'
import TagList from './components/TagList' import TagList from './components/TagList'
import { tempList } from '@renderer/core/share/list' import { tempList } from '@renderer/core/share/list'
export default { export default {
@ -122,7 +121,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.getList(1).then(() => { this.getList(1).then(() => {
this.$nextTick(() => { this.$nextTick(() => {
scrollTo(this.$refs.dom_scrollContent, 0) this.$refs.dom_scrollContent.scrollTo(0, 0)
}) })
}) })
}) })
@ -139,7 +138,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.getList(1).then(() => { this.getList(1).then(() => {
this.$nextTick(() => { this.$nextTick(() => {
scrollTo(this.$refs.dom_scrollContent, 0) this.$refs.dom_scrollContent.scrollTo(0, 0)
}) })
}) })
}) })
@ -231,7 +230,7 @@ export default {
handleToggleListPage(page) { handleToggleListPage(page) {
this.getList(page).then(() => { this.getList(page).then(() => {
this.$nextTick(() => { this.$nextTick(() => {
scrollTo(this.$refs.dom_scrollContent, 0) this.$refs.dom_scrollContent.scrollTo(0, 0)
}) })
}) })
}, },
@ -403,7 +402,9 @@ export default {
align-items: center; align-items: center;
padding-top: 20%; padding-top: 20%;
} }
.songList {
scroll-behavior: smooth;
}
.song-list-header { .song-list-header {
display: flex; display: flex;
flex-flow: row nowrap; flex-flow: row nowrap;