From d2399f76e973cf92d583da93451393c83b186037 Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 14 Oct 2019 15:25:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20picker=E3=80=81picker-view=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E9=BC=A0=E6=A0=87=E6=BB=9A=E8=BD=AE?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=20fixed=20#846?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/picker-view-column/index.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core/view/components/picker-view-column/index.vue b/src/core/view/components/picker-view-column/index.vue index a845998c4..02d4c34a0 100644 --- a/src/core/view/components/picker-view-column/index.vue +++ b/src/core/view/components/picker-view-column/index.vue @@ -68,6 +68,7 @@ export default { this.indicatorClass = $parent.indicatorClass this.maskStyle = $parent.maskStyle this.maskClass = $parent.maskClass + this.deltaY = 0 }, mounted: function () { this.touchtrack(this.$refs.main, '_handleTrack', true) @@ -113,6 +114,18 @@ export default { } } }, + _handleWheel ($event) { + const deltaY = this.deltaY + $event.deltaY + if (Math.abs(deltaY) > 10) { + this.deltaY = 0 + var current = Math.min(this.current + (deltaY < 0 ? -1 : 1), this.length - 1) + this.current = current = Math.max(current, 0) + this._scroller.scrollTo(current * this.indicatorHeight) + } else { + this.deltaY = deltaY + } + $event.preventDefault() + }, setCurrent: function (current) { if (current !== this.current) { this.current = current @@ -152,7 +165,11 @@ export default { }, render (createElement) { this.length = (this.$slots.default && this.$slots.default.length) || 0 - return createElement('uni-picker-view-column', {}, [ + return createElement('uni-picker-view-column', { + on: { + wheel: this._handleWheel + } + }, [ createElement('div', { ref: 'main', staticClass: 'uni-picker-view-group' -- GitLab