Skip to content

Commit

Permalink
fix: 解决 picker、picker-view 组件滚动停止过慢的问题 fixed dcloudio#278 fixed dclou…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed May 16, 2019
1 parent 523a75b commit 63fa0d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/core/view/components/picker-view-column/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script>
import touchtrack from 'uni-mixins/touchtrack'
import scroller from 'uni-mixins/scroller/index'
import { Friction } from 'uni-mixins/scroller/Friction'
import { Spring } from 'uni-mixins/scroller/Spring'
export default {
name: 'PickerViewColumn',
Expand Down Expand Up @@ -108,6 +110,8 @@ export default {
enableX: false,
enableSnap: true,
itemSize: this.indicatorHeight,
friction: new Friction(0.0001),
spring: new Spring(2, 90, 20),
onSnap: (index) => {
if ((!isNaN(index)) && index !== this.current) {
this.current = index
Expand Down
6 changes: 3 additions & 3 deletions src/core/view/mixins/scroller/Scroll.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Friction } from './Friction'
import { Spring } from './Spring'

export function Scroll (extent) {
export function Scroll (extent, friction, spring) {
this._extent = extent
this._friction = new Friction(0.01)
this._spring = new Spring(1, 90, 20)
this._friction = friction || new Friction(0.01)
this._spring = spring || new Spring(1, 90, 20)
this._startTime = 0
this._springing = false
this._springOffset = 0
Expand Down
2 changes: 1 addition & 1 deletion src/core/view/mixins/scroller/Scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function Scroller (element, options) {
}

this._position = 0
this._scroll = new Scroll(this._extent)
this._scroll = new Scroll(this._extent, options.friction, options.spring)
this._onTransitionEnd = this.onTransitionEnd.bind(this)
this.updatePosition()
}
Expand Down

0 comments on commit 63fa0d5

Please sign in to comment.