mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-26 11:26:35 +08:00
Merge branch 'dev' of https://github.com/youzan/vant into dev
This commit is contained in:
commit
ef514d6b16
@ -14,8 +14,9 @@ export default createComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
top: 0,
|
top: 0,
|
||||||
active: false,
|
left: null,
|
||||||
position: 'static'
|
width: null,
|
||||||
|
active: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -27,10 +28,11 @@ export default createComponent({
|
|||||||
anchorStyle() {
|
anchorStyle() {
|
||||||
if (this.sticky) {
|
if (this.sticky) {
|
||||||
return {
|
return {
|
||||||
position: this.position,
|
|
||||||
zIndex: `${this.parent.zIndex}`,
|
zIndex: `${this.parent.zIndex}`,
|
||||||
|
left: this.left ? `${this.left}px` : null,
|
||||||
|
width: this.width ? `${this.width}px` : null,
|
||||||
transform: `translate3d(0, ${this.top}px, 0)`,
|
transform: `translate3d(0, ${this.top}px, 0)`,
|
||||||
color: this.parent.highlightColor,
|
color: this.parent.highlightColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
@import '../style/var';
|
@import '../style/var';
|
||||||
|
|
||||||
.van-index-anchor {
|
.van-index-anchor {
|
||||||
|
box-sizing: border-box;
|
||||||
padding: @index-anchor-padding;
|
padding: @index-anchor-padding;
|
||||||
color: @index-anchor-text-color;
|
color: @index-anchor-text-color;
|
||||||
font-weight: @index-anchor-font-weight;
|
font-weight: @index-anchor-font-weight;
|
||||||
|
@ -19,7 +19,7 @@ export default createComponent({
|
|||||||
mixins: [
|
mixins: [
|
||||||
TouchMixin,
|
TouchMixin,
|
||||||
ParentMixin('vanIndexBar'),
|
ParentMixin('vanIndexBar'),
|
||||||
BindEventMixin(function (bind) {
|
BindEventMixin(function(bind) {
|
||||||
if (!this.scroller) {
|
if (!this.scroller) {
|
||||||
this.scroller = getScrollEventTarget(this.$el);
|
this.scroller = getScrollEventTarget(this.$el);
|
||||||
}
|
}
|
||||||
@ -102,28 +102,27 @@ export default createComponent({
|
|||||||
this.activeAnchorIndex = this.indexList[active];
|
this.activeAnchorIndex = this.indexList[active];
|
||||||
|
|
||||||
if (this.sticky) {
|
if (this.sticky) {
|
||||||
let activeItemTop = 0;
|
this.children.forEach((item, index) => {
|
||||||
let isReachEdge = false;
|
if (index === active || index === active - 1) {
|
||||||
|
const rect = item.$el.getBoundingClientRect();
|
||||||
if (active !== -1) {
|
item.left = rect.left;
|
||||||
activeItemTop = rects[active].top - scrollTop - this.stickyOffsetTop;
|
item.width = rect.width;
|
||||||
isReachEdge = activeItemTop <= 0;
|
} else {
|
||||||
|
item.left = null;
|
||||||
|
item.width = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.children.forEach((item, index) => {
|
|
||||||
if (index === active) {
|
if (index === active) {
|
||||||
item.active = true;
|
item.active = true;
|
||||||
item.position = isReachEdge ? 'fixed' : 'relative';
|
item.top =
|
||||||
item.top = isReachEdge
|
Math.max(this.stickyOffsetTop, rects[index].top - scrollTop) +
|
||||||
? this.stickyOffsetTop + scrollerRect.top
|
scrollerRect.top;
|
||||||
: 0;
|
|
||||||
} else if (index === active - 1) {
|
} else if (index === active - 1) {
|
||||||
item.active = !isReachEdge;
|
const activeItemTop = rects[active].top - scrollTop;
|
||||||
item.position = 'relative';
|
item.active = activeItemTop > 0;
|
||||||
item.top = item.$el.parentElement.offsetHeight - item.height;
|
item.top = activeItemTop + scrollerRect.top - item.height;
|
||||||
} else {
|
} else {
|
||||||
item.active = false;
|
item.active = false;
|
||||||
item.position = 'static';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -133,7 +132,7 @@ export default createComponent({
|
|||||||
const { scroller } = this;
|
const { scroller } = this;
|
||||||
let scrollerRect = {
|
let scrollerRect = {
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (scroller.getBoundingClientRect) {
|
if (scroller.getBoundingClientRect) {
|
||||||
|
@ -34,10 +34,10 @@ exports[`scroll and update active anchor 2`] = `
|
|||||||
<div class="van-index-bar">
|
<div class="van-index-bar">
|
||||||
<div class="van-index-bar__sidebar" style="z-index: 2;"><span data-index="A" class="van-index-bar__index" style="">A</span><span data-index="B" class="van-index-bar__index van-index-bar__index--active" style="color: rgb(7, 193, 96);">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 class="van-index-bar__sidebar" style="z-index: 2;"><span data-index="A" class="van-index-bar__index" style="">A</span><span data-index="B" class="van-index-bar__index van-index-bar__index--active" style="color: rgb(7, 193, 96);">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 data-index="0" style="height: 10px;">
|
<div data-index="0" style="height: 10px;">
|
||||||
<div class="van-index-anchor van-index-anchor--sticky van-hairline--bottom" style="position: relative; z-index: 1; transform: translate3d(0, 0px, 0); color: rgb(7, 193, 96);">1</div>
|
<div class="van-index-anchor van-index-anchor--sticky van-hairline--bottom" style="z-index: 1; transform: translate3d(0, 0px, 0); color: rgb(7, 193, 96);">1</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="1" style="height: 10px;">
|
<div data-index="1" style="height: 10px;">
|
||||||
<div class="van-index-anchor van-index-anchor--sticky van-hairline--bottom" style="position: relative; z-index: 1; transform: translate3d(0, 0px, 0); color: rgb(7, 193, 96);">2</div>
|
<div class="van-index-anchor van-index-anchor--sticky van-hairline--bottom" style="z-index: 1; transform: translate3d(0, 10px, 0); color: rgb(7, 193, 96);">2</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="2">
|
<div data-index="2">
|
||||||
<div class="van-index-anchor">3</div>
|
<div class="van-index-anchor">3</div>
|
||||||
|
@ -140,9 +140,14 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const index = this.getIndexByOffset(this.offset);
|
const index = this.getIndexByOffset(this.offset);
|
||||||
this.moving = false;
|
|
||||||
this.duration = DEFAULT_DURATION;
|
this.duration = DEFAULT_DURATION;
|
||||||
this.setIndex(index, true);
|
this.setIndex(index, true);
|
||||||
|
|
||||||
|
// compatible with desktop scenario
|
||||||
|
// use setTimeout to skip the click event triggered after touchstart
|
||||||
|
setTimeout(() => {
|
||||||
|
this.moving = false;
|
||||||
|
}, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTransitionEnd() {
|
onTransitionEnd() {
|
||||||
|
@ -81,9 +81,11 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
|
|
||||||
&[disabled] {
|
&:disabled {
|
||||||
color: @stepper-input-disabled-text-color;
|
color: @stepper-input-disabled-text-color;
|
||||||
background-color: @stepper-input-disabled-background-color;
|
background-color: @stepper-input-disabled-background-color;
|
||||||
|
-webkit-text-fill-color: @stepper-input-disabled-text-color; // fix disabled color in iOS
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user