Ben Lin
2024-06-27 dfd2d0218bbcea93b4bfb0e7ca7ac9b1cc1cc7da
src/utils/domUtils.ts
@@ -2,11 +2,29 @@
import { upperFirst } from 'lodash-es';
export interface ViewportOffsetResult {
  /**
   * 元素左边距离 body 左边的距离(和 getBoundingClientRect 的 left 一样)
   */
  left: number;
  /**
   * 元素顶边距离 body 顶边的距离(和 getBoundingClientRect 的 top 一样)
   */
  top: number;
  /**
   * 元素右边距离 body 右边的距离
   */
  right: number;
  /**
   * 元素底边距离 body 底边的距离
   */
  bottom: number;
  /**
   * 内容宽度 + 计算后的 right
   */
  rightIncludeBody: number;
  /**
   * 内容高度 + 计算后的 bottom
   */
  bottomIncludeBody: number;
}
@@ -158,7 +176,7 @@
export function once(el: HTMLElement, event: string, fn: EventListener): void {
  const listener = function (this: any, ...args: unknown[]) {
    if (fn) {
      fn.apply(this, args);
      fn.apply(this, args as [evt: Event]);
    }
    off(el, event, listener);
  };