[new feature] Area add 'title' prop & optimzie Picker performance (#450)

This commit is contained in:
neverland
2017-12-19 09:51:09 +08:00
committed by GitHub
parent 72d4365dfc
commit 48b2026e33
11 changed files with 107 additions and 136 deletions

View File

@@ -1,14 +1,15 @@
<template>
<div class="van-picker-column" :class="className" :style="columnStyle">
<div class="van-picker-column__frame van-hairline--top-bottom" :style="frameStyle" />
<ul
:style="wrapperStyle"
@touchstart="onTouchStart"
@touchmove.prevent="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
>
<div
class="van-picker-column"
:class="className"
:style="columnStyle"
@touchstart="onTouchStart"
@touchmove.prevent="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
>
<ul :style="wrapperStyle">
<li
v-for="(option, index) in options"
v-text="getOptionText(option)"
@@ -34,14 +35,11 @@ export default create({
props: {
valueKey: String,
className: String,
itemHeight: Number,
options: {
type: Array,
default: () => []
},
itemHeight: {
type: Number,
default: 44
},
visibileColumnCount: {
type: Number,
default: 5
@@ -95,6 +93,10 @@ export default create({
return this.options.length;
},
baseOffset() {
return this.itemHeight * (this.visibileColumnCount - 1) / 2;
},
columnStyle() {
return {
height: (this.itemHeight * this.visibileColumnCount) + 'px'
@@ -104,15 +106,8 @@ export default create({
wrapperStyle() {
return {
transition: `${this.duration}ms`,
transform: `translate3d(0, ${this.offset}px, 0)`,
lineHeight: this.itemHeight + 'px',
padding: `${this.itemHeight * (this.visibileColumnCount - 1) / 2}px 0`
};
},
frameStyle() {
return {
height: this.itemHeight + 'px'
transform: `translate3d(0, ${this.offset + this.baseOffset}px, 0)`,
lineHeight: this.itemHeight + 'px'
};
},