Skip to content

Commit

Permalink
fix(popup): trigger on-scroll-to-bottom on windows (#2404)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn authored May 11, 2023
1 parent 5c1db91 commit cc1a0c2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/popup/popup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { VNodeDirective } from 'vue';
import { createPopper } from '@popperjs/core';
import debounce from 'lodash/debounce';
import { on, off, once } from '../utils/dom';
import { renderTNodeJSX, renderContent } from '../utils/render-tnode';
import { getIEVersion } from '../utils/helper';
Expand Down Expand Up @@ -255,9 +256,13 @@ export default mixins(classPrefixMixins).extend({
},
handleOnScroll(e: WheelEvent) {
const { scrollTop, clientHeight, scrollHeight } = e.target as HTMLDivElement;
if (scrollHeight - scrollTop === clientHeight) {
// 防止多次触发添加截流
const debounceOnScrollBottom = debounce((e) => emitEvent(this, 'scroll-to-bottom', { e }), 100);

// windows 下 scrollTop 会出现小数,这里取整
if (clientHeight + Math.floor(scrollTop) === scrollHeight) {
// touch bottom
emitEvent(this, 'scroll-to-bottom', { e });
debounceOnScrollBottom(e);
}
emitEvent(this, 'scroll', { e });
},
Expand Down

0 comments on commit cc1a0c2

Please sign in to comment.