Skip to content

Commit

Permalink
fix(ui): issues with Firefox and Mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye64 committed Nov 3, 2019
1 parent 8339c48 commit 9633dae
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions ui/src/component/mixins/scroller-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { QColorizeMixin } from 'q-colorize-mixin'

// Utils
import props from '../utils/props'
import { debounce, QBtn, QResizeObserver, scroll } from 'quasar'
import {
debounce,
QBtn,
QResizeObserver,
scroll
} from 'quasar'

// tree shake other scroll functions
const { getScrollPosition, setScrollPosition, getScrollTarget } = scroll
Expand Down Expand Up @@ -226,24 +231,29 @@ export default {

getItemIndexFromEvent (event) {
const top = event.target.scrollTop
return Math.floor(top / this.itemHeight)
return Math.round(top / this.itemHeight)
},

scrollEvent: debounce(function (event) {
if (this.$q.platform.is.desktop) {
return
}
if (this.disable !== true) {
const index = this.getItemIndexFromEvent(event)
if (index > -1 && index < this.items.length) {
const item = this.items[index]
if (this.disable !== true && item.disabled !== true) {
this.$emit('input', this.value)
if (item.value !== this.value) {
this.$emit('input', item.value)
}
}
event.preventDefault()
} else {
/* eslint-disable-next-line */
console.error(`QScroller: index (${index}) is out of bounds (${this.items.length})`)
}
}
}, 500),
}, 250),

clickEvent (item) {
if (this.disable !== true && item.disabled !== true) {
Expand Down Expand Up @@ -329,8 +339,7 @@ export default {
return h('div', this.setBothColors(this.textColor, void 0, {
staticClass: 'q-scroller__body',
on: {
mousewheel: (event) => this.wheelEvent(event),
scroll: (event) => this.scrollEvent(event)
wheel: (event) => this.wheelEvent(event)
}
}), [
this.__renderPadding(h),
Expand All @@ -354,7 +363,8 @@ export default {
'q-scroller__overflow-hidden': this.$q.platform.is.mobile !== true
},
on: {
...this.$listeners
...this.$listeners,
scroll: (event) => this.scrollEvent(event)
}
}, resize.concat([
this.__renderContents(h)
Expand Down

0 comments on commit 9633dae

Please sign in to comment.