Function scrollXTo

  • X 轴滚动到指定位置

    Parameters

    • targetVal: number | "start" | "end"

      'start' | 'end' | number

    • callback: any

      回调

    • dom: any = document.documentElement

      元素对象

    Returns void

    scrollXTo(0); /// 滚动到左侧
    scrollXTo('start', null, document.documentElement); /// 滚动到左侧
    scrollXTo('end', (percent) => console.log(percent), document.querySelector('body')); /// 滚动到右侧