mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
fix(ImagePreview): should emit change event when reset to start position (#4320)
This commit is contained in:
@@ -104,12 +104,11 @@ export default createComponent({
|
|||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
value() {
|
value() {
|
||||||
this.resetScale();
|
this.setActive(this.startPosition);
|
||||||
this.active = this.startPosition;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startPosition(active) {
|
startPosition(active) {
|
||||||
this.active = active;
|
this.setActive(active);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -233,10 +232,13 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onSwipeChange(active) {
|
setActive(active) {
|
||||||
this.resetScale();
|
this.resetScale();
|
||||||
this.active = active;
|
|
||||||
this.$emit('change', active);
|
if (active !== this.active) {
|
||||||
|
this.active = active;
|
||||||
|
this.$emit('change', active);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
resetScale() {
|
resetScale() {
|
||||||
@@ -275,7 +277,7 @@ export default createComponent({
|
|||||||
indicatorColor="white"
|
indicatorColor="white"
|
||||||
initialSwipe={this.startPosition}
|
initialSwipe={this.startPosition}
|
||||||
showIndicators={this.showIndicators}
|
showIndicators={this.showIndicators}
|
||||||
onChange={this.onSwipeChange}
|
onChange={this.setActive}
|
||||||
>
|
>
|
||||||
{images.map((image, index) => {
|
{images.map((image, index) => {
|
||||||
const props = {
|
const props = {
|
||||||
|
Reference in New Issue
Block a user