滚动实用程序
滚动容器确定
值得阅读这里以了解是怎么做到的
import { scroll } from 'quasar' const { getScrollTarget } = scroll
(DOM Element) getScrollTarget(DomElement)
|
获取/设置滚动位置
import { scroll } from 'quasar' const { getScrollPosition, setScrollPosition } = scroll
(Number pixels) getScrollPosition(scrollTargetDomElement)
setScrollPosition (scrollTargetElement, offset[, duration])
|
滚动到元素
使用scroll utils滚动到元素的完整示例:
import { scroll } from 'quasar' const { getScrollTarget, setScrollPosition } = scroll
function scrollToElement (el) { let target = getScrollTarget(el) let offset = el.offsetTop - el.scrollHeight let duration = 1000 setScrollPosition(target, offset, duration) }
|
滚动高度确定
import { scroll } from 'quasar' const { getScrollHeight } = scroll
(Number) getScrollHeight(scrollTargetDomElement)
console.log( getScrollHeight(el) )
|
滚动条宽度确定
以像素为单位计算滚动条的宽度。
import { scroll } from 'quasar' const { getScrollbarWidth } = scroll
console.log(getScrollbarWidth())
|