[improvement] IndexBar: unify index dataset

This commit is contained in:
陈嘉涵 2019-05-30 19:12:41 +08:00
parent 0678c7d30b
commit a412c605d1
4 changed files with 13 additions and 10 deletions

View File

@ -21,6 +21,10 @@
- 新增`gutter`属性
- 支持`String`类型的`size`属性
##### Search
- 优化输入体验,输入法拼写过程中不再会触发`v-model`更新
##### SwipeCell
- 支持自动计算`left-width``right-width`

View File

@ -40,7 +40,7 @@ export default sfc({
data() {
return {
activeAnchorIndex: -1
activeAnchorIndex: null
};
},
@ -95,7 +95,7 @@ export default sfc({
const active = this.getActiveAnchorIndex(scrollTop, rects);
this.activeAnchorIndex = active;
this.activeAnchorIndex = this.indexList[active];
this.children.forEach((item, index) => {
if (index === active) {
item.active = true;
@ -137,11 +137,11 @@ export default sfc({
const { clientX, clientY } = event.touches[0];
const target = document.elementFromPoint(clientX, clientY);
if (target) {
const { idx } = target.dataset;
const { index } = target.dataset;
/* istanbul ignore else */
if (this.touchActiveIdx !== idx) {
this.touchActiveIdx = idx;
if (this.touchActiveIndex !== index) {
this.touchActiveIndex = index;
this.scrollToElement(target);
}
}
@ -178,11 +178,10 @@ export default sfc({
onTouchend={this.onTouchEnd}
onTouchcancel={this.onTouchEnd}
>
{this.indexList.map((index, idx) => (
{this.indexList.map(index => (
<span
class={bem('index')}
style={idx === this.activeAnchorIndex ? this.highlightStyle : null}
data-idx={idx}
style={index === this.activeAnchorIndex ? this.highlightStyle : null}
data-index={index}
>
{index}

View File

@ -13,7 +13,7 @@ exports[`renders demo correctly 1`] = `
<div class="van-tabs__content">
<div role="tabpanel" class="van-tab__pane" style="">
<div class="van-index-bar">
<div class="van-index-bar__sidebar" style="z-index: 1;"><span data-idx="0" data-index="A" class="van-index-bar__index">A</span><span data-idx="1" data-index="B" class="van-index-bar__index">B</span><span data-idx="2" data-index="C" class="van-index-bar__index">C</span><span data-idx="3" data-index="D" class="van-index-bar__index">D</span><span data-idx="4" data-index="E" class="van-index-bar__index">E</span><span data-idx="5" data-index="F" class="van-index-bar__index">F</span><span data-idx="6" data-index="G" class="van-index-bar__index">G</span><span data-idx="7" data-index="H" class="van-index-bar__index">H</span><span data-idx="8" data-index="I" class="van-index-bar__index">I</span><span data-idx="9" data-index="J" class="van-index-bar__index">J</span><span data-idx="10" data-index="K" class="van-index-bar__index">K</span><span data-idx="11" data-index="L" class="van-index-bar__index">L</span><span data-idx="12" data-index="M" class="van-index-bar__index">M</span><span data-idx="13" data-index="N" class="van-index-bar__index">N</span><span data-idx="14" data-index="O" class="van-index-bar__index">O</span><span data-idx="15" data-index="P" class="van-index-bar__index">P</span><span data-idx="16" data-index="Q" class="van-index-bar__index">Q</span><span data-idx="17" data-index="R" class="van-index-bar__index">R</span><span data-idx="18" data-index="S" class="van-index-bar__index">S</span><span data-idx="19" data-index="T" class="van-index-bar__index">T</span><span data-idx="20" data-index="U" class="van-index-bar__index">U</span><span data-idx="21" data-index="V" class="van-index-bar__index">V</span><span data-idx="22" data-index="W" class="van-index-bar__index">W</span><span data-idx="23" data-index="X" class="van-index-bar__index">X</span><span data-idx="24" data-index="Y" class="van-index-bar__index">Y</span><span data-idx="25" data-index="Z" class="van-index-bar__index">Z</span></div>
<div class="van-index-bar__sidebar" style="z-index: 1;"><span data-index="A" class="van-index-bar__index">A</span><span data-index="B" class="van-index-bar__index">B</span><span data-index="C" class="van-index-bar__index">C</span><span data-index="D" class="van-index-bar__index">D</span><span data-index="E" class="van-index-bar__index">E</span><span data-index="F" class="van-index-bar__index">F</span><span data-index="G" class="van-index-bar__index">G</span><span data-index="H" class="van-index-bar__index">H</span><span data-index="I" class="van-index-bar__index">I</span><span data-index="J" class="van-index-bar__index">J</span><span data-index="K" class="van-index-bar__index">K</span><span data-index="L" class="van-index-bar__index">L</span><span data-index="M" class="van-index-bar__index">M</span><span data-index="N" class="van-index-bar__index">N</span><span data-index="O" class="van-index-bar__index">O</span><span data-index="P" class="van-index-bar__index">P</span><span data-index="Q" class="van-index-bar__index">Q</span><span data-index="R" class="van-index-bar__index">R</span><span data-index="S" class="van-index-bar__index">S</span><span data-index="T" class="van-index-bar__index">T</span><span data-index="U" class="van-index-bar__index">U</span><span data-index="V" class="van-index-bar__index">V</span><span data-index="W" class="van-index-bar__index">W</span><span data-index="X" class="van-index-bar__index">X</span><span data-index="Y" class="van-index-bar__index">Y</span><span data-index="Z" class="van-index-bar__index">Z</span></div>
<div>
<div>
<div class="van-index-anchor">A</div>

View File

@ -2,7 +2,7 @@
exports[`custom anchor text 1`] = `
<div class="van-index-bar">
<div class="van-index-bar__sidebar" style="z-index: 1;"><span data-idx="0" data-index="A" class="van-index-bar__index">A</span><span data-idx="1" data-index="B" class="van-index-bar__index">B</span><span data-idx="2" data-index="C" class="van-index-bar__index">C</span><span data-idx="3" data-index="D" class="van-index-bar__index">D</span><span data-idx="4" data-index="E" class="van-index-bar__index">E</span><span data-idx="5" data-index="F" class="van-index-bar__index">F</span><span data-idx="6" data-index="G" class="van-index-bar__index">G</span><span data-idx="7" data-index="H" class="van-index-bar__index">H</span><span data-idx="8" data-index="I" class="van-index-bar__index">I</span><span data-idx="9" data-index="J" class="van-index-bar__index">J</span><span data-idx="10" data-index="K" class="van-index-bar__index">K</span><span data-idx="11" data-index="L" class="van-index-bar__index">L</span><span data-idx="12" data-index="M" class="van-index-bar__index">M</span><span data-idx="13" data-index="N" class="van-index-bar__index">N</span><span data-idx="14" data-index="O" class="van-index-bar__index">O</span><span data-idx="15" data-index="P" class="van-index-bar__index">P</span><span data-idx="16" data-index="Q" class="van-index-bar__index">Q</span><span data-idx="17" data-index="R" class="van-index-bar__index">R</span><span data-idx="18" data-index="S" class="van-index-bar__index">S</span><span data-idx="19" data-index="T" class="van-index-bar__index">T</span><span data-idx="20" data-index="U" class="van-index-bar__index">U</span><span data-idx="21" data-index="V" class="van-index-bar__index">V</span><span data-idx="22" data-index="W" class="van-index-bar__index">W</span><span data-idx="23" data-index="X" class="van-index-bar__index">X</span><span data-idx="24" data-index="Y" class="van-index-bar__index">Y</span><span data-idx="25" data-index="Z" class="van-index-bar__index">Z</span></div>
<div class="van-index-bar__sidebar" style="z-index: 1;"><span data-index="A" class="van-index-bar__index">A</span><span data-index="B" class="van-index-bar__index">B</span><span data-index="C" class="van-index-bar__index">C</span><span data-index="D" class="van-index-bar__index">D</span><span data-index="E" class="van-index-bar__index">E</span><span data-index="F" class="van-index-bar__index">F</span><span data-index="G" class="van-index-bar__index">G</span><span data-index="H" class="van-index-bar__index">H</span><span data-index="I" class="van-index-bar__index">I</span><span data-index="J" class="van-index-bar__index">J</span><span data-index="K" class="van-index-bar__index">K</span><span data-index="L" class="van-index-bar__index">L</span><span data-index="M" class="van-index-bar__index">M</span><span data-index="N" class="van-index-bar__index">N</span><span data-index="O" class="van-index-bar__index">O</span><span data-index="P" class="van-index-bar__index">P</span><span data-index="Q" class="van-index-bar__index">Q</span><span data-index="R" class="van-index-bar__index">R</span><span data-index="S" class="van-index-bar__index">S</span><span data-index="T" class="van-index-bar__index">T</span><span data-index="U" class="van-index-bar__index">U</span><span data-index="V" class="van-index-bar__index">V</span><span data-index="W" class="van-index-bar__index">W</span><span data-index="X" class="van-index-bar__index">X</span><span data-index="Y" class="van-index-bar__index">Y</span><span data-index="Z" class="van-index-bar__index">Z</span></div>
<div>
<div class="van-index-anchor">Title A</div>
</div>