Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
refresh() {
const scroller = this.scroll.scroller
const scrollBehaviorY = scroller.scrollBehaviorY
// adjust contentSize
const contentRect = getRect(scroller.content)
scrollBehaviorY.contentSize = contentRect.height
this.items = scroller.content.children
this.checkWheelAllDisabled()
this.itemHeight = this.items.length
? scrollBehaviorY.contentSize / this.items.length
: 0
if (this.selectedIndex === undefined) {
this.selectedIndex = this.options.selectedIndex || 0
}
this.scroll.maxScrollX = 0
this.scroll.maxScrollY = -this.itemHeight * (this.items.length - 1)
this.scroll.minScrollX = 0
refresh() {
const { size, position } = this.options.rect
const isWrapperStatic =
window.getComputedStyle(this.wrapper, null).position === 'static'
const wrapperRect = getRect(this.wrapper)
this.wrapperSize = wrapperRect[size]
const contentRect = getRect(this.content)
this.contentSize = contentRect[size]
this.relativeOffset = contentRect[position]
if (isWrapperStatic) {
this.relativeOffset -= wrapperRect[position]
}
this.minScrollPos = 0
this.maxScrollPos = this.wrapperSize - this.contentSize
if (this.maxScrollPos < 0) {
this.maxScrollPos -= this.relativeOffset
this.minScrollPos = -this.relativeOffset
}
function check() {
if (me.stopObserver) {
return
}
scrollerRect = getRect(scrollerEl)
let newWidth = scrollerRect.width
let newHeight = scrollerRect.height
if (oldWidth !== newWidth || oldHeight !== newHeight) {
scrollIns.refresh()
}
oldWidth = newWidth
oldHeight = newHeight
next()
}
private checkDOMUpdate() {
const me = this
const scrollIns = this.scroll
const scrollerEl = scrollIns.scroller.content
let scrollerRect = getRect(scrollerEl)
let oldWidth = scrollerRect.width
let oldHeight = scrollerRect.height
function check() {
if (me.stopObserver) {
return
}
scrollerRect = getRect(scrollerEl)
let newWidth = scrollerRect.width
let newHeight = scrollerRect.height
if (oldWidth !== newWidth || oldHeight !== newHeight) {
scrollIns.refresh()
}
oldWidth = newWidth
oldHeight = newHeight