调整滚动到view

This commit is contained in:
kuaifan 2022-06-03 19:27:39 +08:00
parent 6eeeb733e2
commit b8234adbc2
5 changed files with 24 additions and 18 deletions

View File

@ -1045,6 +1045,21 @@
}
},
/**
* 按需滚动到View
* @param element
*/
scrollIntoViewIfNeeded(element) {
if (!element) {
return;
}
if (typeof element.scrollIntoViewIfNeeded === "function") {
element.scrollIntoViewIfNeeded()
} else {
$A.scrollToView(element, {block: "nearest", inline: "nearest"})
}
},
/**
* 等比缩放尺寸
* @param width

View File

@ -1030,10 +1030,7 @@ export default {
this.$nextTick(() => {
const active = this.$refs.menuProject.querySelector(".active")
if (active) {
$A.scrollToView(active, {
behavior: 'instant',
scrollMode: 'if-needed',
});
$A.scrollIntoViewIfNeeded(active);
}
});
}).catch(({msg}) => {

View File

@ -385,7 +385,7 @@ export default {
} else if (!this.$isDesktop) {
this.timerScroll = setInterval(() => {
if (this.quill?.hasFocus()) {
this.$refs.editor.scrollIntoViewIfNeeded();
$A.scrollIntoViewIfNeeded(this.$refs.editor);
} else {
clearInterval(this.timerScroll);
}

View File

@ -10,7 +10,10 @@
<div
class="dialog-content"
:class="contentClass"
v-longpress="handleLongpress">
v-longpress="{
delay: 300,
callback: handleLongpress
}">
<!--文本-->
<div v-if="msgData.type === 'text'" class="content-text no-dark-content">
<pre @click="viewText" v-html="textMsg(msgData.msg.text)"></pre>

View File

@ -382,10 +382,7 @@ export default {
//
const dialog = this.dialogList.find(dialog => $A.getDialogUnread(dialog) > 0)
if (dialog) {
$A.scrollToView(this.$refs[`dialog_${dialog.id}`][0], {
behavior: 'smooth',
scrollMode: 'if-needed',
})
$A.scrollIntoViewIfNeeded(this.$refs[`dialog_${dialog.id}`][0])
}
}
this.dialogActive = type
@ -517,10 +514,7 @@ export default {
if (this.$isDesktop && this.$refs.list) {
const active = this.$refs.list.querySelector(".active")
if (active) {
$A.scrollToView(active, {
behavior: 'instant',
scrollMode: 'if-needed',
});
$A.scrollIntoViewIfNeeded(active);
} else {
const dialog = this.cacheDialogs.find(({id}) => id == this.dialogId)
if (dialog && this.dialogActive) {
@ -528,10 +522,7 @@ export default {
this.$nextTick(() => {
const active = this.$refs.list.querySelector(".active")
if (active) {
$A.scrollToView(active, {
behavior: 'instant',
scrollMode: 'if-needed',
});
$A.scrollIntoViewIfNeeded(active);
}
});
}