| | |
| | | |
| | | export const useScroll = (option: UseScrollOption) => { |
| | | const { chatListDom } = option; |
| | | |
| | | const scrollStepToBottom = () => { |
| | | const allStepList = document.querySelectorAll('.step-list'); |
| | | const lastStepList = allStepList[allStepList.length - 1]; |
| | | if (!lastStepList) return; |
| | | lastStepList.scrollTop = lastStepList.scrollHeight - lastStepList.clientHeight; |
| | | }; |
| | | const scrollToBottom = () => { |
| | | nextTick(() => { |
| | | if (chatListDom.value.scrollHeight > chatListDom.value.clientHeight) { |
| | | chatListDom.value.scrollTop = chatListDom.value.scrollHeight - chatListDom.value.clientHeight; |
| | | nextTick(() => { |
| | | scrollStepToBottom(); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | |
| | | chatListDom.value.scrollTop = 0; |
| | | }); |
| | | }; |
| | | |
| | | |
| | | const checkIsBottom = () => { |
| | | // 误差 2像素 |
| | |
| | | }); |
| | | |
| | | onUnmounted(() => { |
| | | chatListDom.value.removeEventListener('scrollend', checkIsBottom); |
| | | chatListDom.value?.removeEventListener('scrollend', checkIsBottom); |
| | | }); |
| | | |
| | | // emitter.on('amis.page.ready', debounceAmisScroll); |