feat(ImagePreview): reset scale after swiping (#7974)

* feat(ImagePreview): reset scale after swiping

* fix: should not emit scale event

* fix(Calendar): watch type and reset
This commit is contained in:
neverland 2021-01-23 16:21:36 +08:00 committed by GitHub
parent c532be87ff
commit d20224a47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -151,9 +151,12 @@ export default createComponent({
}, },
watch: { watch: {
type: 'reset',
value: 'init', value: 'init',
type() {
this.reset();
},
defaultDate(val) { defaultDate(val) {
this.currentDate = val; this.currentDate = val;
this.scrollIntoView(); this.scrollIntoView();

View File

@ -92,6 +92,8 @@ export default {
}, },
watch: { watch: {
active: 'resetScale',
show(val) { show(val) {
if (!val) { if (!val) {
this.resetScale(); this.resetScale();
@ -111,11 +113,15 @@ export default {
}, },
setScale(scale) { setScale(scale) {
this.scale = range(scale, +this.minZoom, +this.maxZoom); scale = range(scale, +this.minZoom, +this.maxZoom);
if (scale !== this.scale) {
this.scale = scale;
this.$emit('scale', { this.$emit('scale', {
scale: this.scale, scale: this.scale,
index: this.active, index: this.active,
}); });
}
}, },
toggleScale() { toggleScale() {