From 5fe840ad2b4574d469228db70f801bd90df0e6cf Mon Sep 17 00:00:00 2001 From: rex Date: Tue, 18 Dec 2018 14:01:25 +0800 Subject: [PATCH] =?UTF-8?q?[bugfix]=20Stepper:=20=E4=BF=AE=E5=A4=8DiPad?= =?UTF-8?q?=E4=B8=8B=E6=88=96=E4=BF=AE=E6=94=B9input=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E6=97=B6=E8=BE=93=E5=85=A5=E6=A1=86=E6=A0=B7=E5=BC=8F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20(#1086)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/pages/stepper/index.wxss | 2 +- packages/stepper/index.less | 41 +++++++++++++++++++------------- packages/stepper/index.ts | 10 ++++++++ packages/stepper/index.wxml | 19 ++++++++------- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/example/pages/stepper/index.wxss b/example/pages/stepper/index.wxss index 1f476854..27f2c4ac 100644 --- a/example/pages/stepper/index.wxss +++ b/example/pages/stepper/index.wxss @@ -1 +1 @@ -/* pages/stepper/index.wxss */ \ No newline at end of file +/* pages/stepper/index.wxss */ diff --git a/packages/stepper/index.less b/packages/stepper/index.less index dde4dbc8..1f352746 100644 --- a/packages/stepper/index.less +++ b/packages/stepper/index.less @@ -5,7 +5,7 @@ &__minus, &__plus, - &__input { + &__input-wrapper { display: inline-block; vertical-align: middle; background-color: @white; @@ -13,12 +13,12 @@ &__minus, &__plus { + position: relative; width: 40px; height: 30px; - box-sizing: border-box; - border: 1px solid @border-color; - position: relative; padding: 5px; + border: 1px solid @border-color; + box-sizing: border-box; &::before { width: 9px; @@ -32,14 +32,14 @@ &::before, &::after { - content: ''; position: absolute; - margin: auto; top: 0; - left: 0; right: 0; bottom: 0; + left: 0; + margin: auto; background-color: @gray-darker; + content: ''; } &:active { @@ -72,23 +72,32 @@ border-radius: 0 2px 2px 0; } - &__input { - width: 33px; - height: 26px; + &__input-wrapper { + position: relative; + width: 35px; + height: 30px; padding: 1px; - min-height: 0; // reset wechat default min height + font-size: 14px; + color: @gray-darker; + text-align: center; border: 1px solid @border-color; border-width: 1px 0; border-radius: 0; - box-sizing: content-box; - color: @gray-darker; - font-size: 14px; - text-align: center; - -webkit-appearance: none; + box-sizing: border-box; &--disabled { color: @gray; background-color: @background-color; } } + + &__input { + position: absolute; + top: 50%; + left: 50%; + width: 100%; + min-height: 0; // reset wechat default min height + transform: translate3d(-50%, -50%, 0); + appearance: none; + } } diff --git a/packages/stepper/index.ts b/packages/stepper/index.ts index 9b54fbae..27ee09e5 100644 --- a/packages/stepper/index.ts +++ b/packages/stepper/index.ts @@ -50,6 +50,10 @@ VantComponent({ } }, + data: { + focus: false + }, + created() { this.set({ value: this.range(this.data.value) @@ -57,6 +61,12 @@ VantComponent({ }, methods: { + onFocus() { + this.setData({ + focus: true + }); + }, + // limit value range range(value) { return Math.max(Math.min(this.data.max, value), this.data.min); diff --git a/packages/stepper/index.wxml b/packages/stepper/index.wxml index b7363152..b31068f4 100644 --- a/packages/stepper/index.wxml +++ b/packages/stepper/index.wxml @@ -3,14 +3,17 @@ class="minus-class van-stepper__minus {{ minusDisabled ? 'van-stepper__minus--disabled' : '' }}" bind:tap="onMinus" /> - + + +