Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-06-11 20:53:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
05564db04ab71c6a27cbe7d5b55eb49998847067
05564db0
1 parent
5e7e116d
feat(StudyDetailPage): 添加目录弹框打开时自动滚动到当前课程功能
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletions
src/views/study/StudyDetailPage.vue
src/views/study/StudyDetailPage.vue
View file @
05564db
...
...
@@ -847,12 +847,40 @@ const endAction = (item) => {
}
/**
*
新增
记录
*
添加学习
记录
* @param paramsObj
*/
const addRecord = async (paramsObj) => {
await addStudyRecordAPI(paramsObj);
}
// 监听目录弹框显示状态,当打开时滚动到当前课程位置
watch(showCatalog, (newVal) => {
if (newVal) {
// 等待DOM更新后执行滚动
nextTick(() => {
// 查找当前选中的课程元素
const selectedLesson = document.querySelector('.text-green-600')?.closest('.bg-white');
if (selectedLesson) {
// 获取滚动容器
const scrollContainer = document.querySelector('.van-popup .overflow-y-auto');
if (scrollContainer) {
// 计算滚动位置,使选中元素位于容器中间
const containerHeight = scrollContainer.clientHeight;
const lessonTop = selectedLesson.offsetTop;
const lessonHeight = selectedLesson.clientHeight;
const scrollTop = lessonTop - (containerHeight / 2) + (lessonHeight / 2);
// 平滑滚动到指定位置
scrollContainer.scrollTo({
top: scrollTop,
behavior: 'smooth'
});
}
}
});
}
});
</script>
<style lang="less" scoped>
...
...
Please
register
or
login
to post a comment