diff --git a/dist/dialog/dialog.d.ts b/dist/dialog/dialog.d.ts index bb00408f..17708107 100644 --- a/dist/dialog/dialog.d.ts +++ b/dist/dialog/dialog.d.ts @@ -14,6 +14,9 @@ interface DialogOptions { overlay?: boolean; selector?: string; ariaLabel?: string; + /** + * @deprecated use custom-class instead + */ className?: string; customStyle?: string; transition?: string; diff --git a/dist/dialog/index.wxml b/dist/dialog/index.wxml index f49dee40..72336428 100644 --- a/dist/dialog/index.wxml +++ b/dist/dialog/index.wxml @@ -5,7 +5,7 @@ z-index="{{ zIndex }}" overlay="{{ overlay }}" transition="{{ transition }}" - custom-class="van-dialog van-dialog--{{ theme }} {{ className }}" + custom-class="van-dialog van-dialog--{{ theme }}{{ className }} custom-class" custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}" overlay-style="{{ overlayStyle }}" close-on-click-overlay="{{ closeOnClickOverlay }}" diff --git a/dist/slider/index.js b/dist/slider/index.js index 0530f6b9..3f5fdf79 100644 --- a/dist/slider/index.js +++ b/dist/slider/index.js @@ -1,7 +1,12 @@ import { VantComponent } from '../common/component'; import { touch } from '../mixins/touch'; import { canIUseModel } from '../common/version'; -import { getRect, addUnit } from '../common/utils'; +import { getRect, addUnit, nextTick } from '../common/utils'; +const DRAG_STATUS = { + START: 'start', + MOVING: 'moving', + END: 'end', +}; VantComponent({ mixins: [touch], props: { @@ -54,16 +59,16 @@ VantComponent({ else { this.startValue = this.format(this.newValue); } - this.dragStatus = 'start'; + this.dragStatus = DRAG_STATUS.START; }, onTouchMove(event) { if (this.data.disabled) return; - if (this.dragStatus === 'start') { + if (this.dragStatus === DRAG_STATUS.START) { this.$emit('drag-start'); } this.touchMove(event); - this.dragStatus = 'draging'; + this.dragStatus = DRAG_STATUS.MOVING; getRect(this, '.van-slider').then((rect) => { const { vertical } = this.data; const delta = vertical ? this.deltaY : this.deltaX; @@ -82,9 +87,12 @@ VantComponent({ onTouchEnd() { if (this.data.disabled) return; - if (this.dragStatus === 'draging') { - this.updateValue(this.newValue, true); - this.$emit('drag-end'); + if (this.dragStatus === DRAG_STATUS.MOVING) { + this.dragStatus = DRAG_STATUS.END; + nextTick(() => { + this.updateValue(this.newValue, true); + this.$emit('drag-end'); + }); } }, onClick(event) { @@ -166,7 +174,7 @@ VantComponent({ getOffsetWidth(current, min) { const scope = this.getScope(); // 避免最小值小于最小step时出现负数情况 - return `${Math.max((current - min) * 100 / scope, 0)}%`; + return `${Math.max(((current - min) * 100) / scope, 0)}%`; }, // 计算选中条的长度百分比 calcMainAxis() { diff --git a/dist/stepper/index.js b/dist/stepper/index.js index 8a27a011..a2a80880 100644 --- a/dist/stepper/index.js +++ b/dist/stepper/index.js @@ -96,7 +96,6 @@ VantComponent({ }, onBlur(event) { const value = this.format(event.detail.value); - this.emitChange(value); this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value })); }, // filter illegal characters diff --git a/dist/tabs/index.js b/dist/tabs/index.js index ecbb3327..2fcd5d6d 100644 --- a/dist/tabs/index.js +++ b/dist/tabs/index.js @@ -83,6 +83,7 @@ VantComponent({ skipTransition: true, scrollWithAnimation: false, lineOffsetLeft: 0, + inited: false, }, mounted() { requestAnimationFrame(() => { @@ -191,12 +192,13 @@ VantComponent({ .reduce((prev, curr) => prev + curr.width, 0); lineOffsetLeft += (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8); - this.setData({ lineOffsetLeft }); + this.setData({ lineOffsetLeft, inited: true }); this.swiping = true; if (skipTransition) { - nextTick(() => { + // waiting transition end + setTimeout(() => { this.setData({ skipTransition: false }); - }); + }, this.data.duration); } }); }, diff --git a/dist/tabs/index.wxml b/dist/tabs/index.wxml index f76dd63f..6fcb57f0 100644 --- a/dist/tabs/index.wxml +++ b/dist/tabs/index.wxml @@ -20,7 +20,7 @@ style="{{ color ? 'border-color: ' + color : '' }}" > - + ; diff --git a/dist/uploader/utils.js b/dist/uploader/utils.js index b77f7078..cf92e4fc 100644 --- a/dist/uploader/utils.js +++ b/dist/uploader/utils.js @@ -38,7 +38,7 @@ function formatMedia(res) { function formatFile(res) { return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { url: item.path }))); } -export function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, }) { +export function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, mediaType, }) { return new Promise((resolve, reject) => { switch (accept) { case 'image': @@ -53,6 +53,7 @@ export function chooseFile({ accept, multiple, capture, compressed, maxDuration, case 'media': wx.chooseMedia({ count: multiple ? Math.min(maxCount, 9) : 1, + mediaType, sourceType: capture, maxDuration, sizeType, diff --git a/lib/dialog/dialog.d.ts b/lib/dialog/dialog.d.ts index bb00408f..17708107 100644 --- a/lib/dialog/dialog.d.ts +++ b/lib/dialog/dialog.d.ts @@ -14,6 +14,9 @@ interface DialogOptions { overlay?: boolean; selector?: string; ariaLabel?: string; + /** + * @deprecated use custom-class instead + */ className?: string; customStyle?: string; transition?: string; diff --git a/lib/dialog/index.wxml b/lib/dialog/index.wxml index f49dee40..72336428 100644 --- a/lib/dialog/index.wxml +++ b/lib/dialog/index.wxml @@ -5,7 +5,7 @@ z-index="{{ zIndex }}" overlay="{{ overlay }}" transition="{{ transition }}" - custom-class="van-dialog van-dialog--{{ theme }} {{ className }}" + custom-class="van-dialog van-dialog--{{ theme }}{{ className }} custom-class" custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}" overlay-style="{{ overlayStyle }}" close-on-click-overlay="{{ closeOnClickOverlay }}" diff --git a/lib/slider/index.js b/lib/slider/index.js index 61a80a19..73923a23 100644 --- a/lib/slider/index.js +++ b/lib/slider/index.js @@ -4,6 +4,11 @@ var component_1 = require("../common/component"); var touch_1 = require("../mixins/touch"); var version_1 = require("../common/version"); var utils_1 = require("../common/utils"); +var DRAG_STATUS = { + START: 'start', + MOVING: 'moving', + END: 'end', +}; (0, component_1.VantComponent)({ mixins: [touch_1.touch], props: { @@ -57,17 +62,17 @@ var utils_1 = require("../common/utils"); else { this.startValue = this.format(this.newValue); } - this.dragStatus = 'start'; + this.dragStatus = DRAG_STATUS.START; }, onTouchMove: function (event) { var _this = this; if (this.data.disabled) return; - if (this.dragStatus === 'start') { + if (this.dragStatus === DRAG_STATUS.START) { this.$emit('drag-start'); } this.touchMove(event); - this.dragStatus = 'draging'; + this.dragStatus = DRAG_STATUS.MOVING; (0, utils_1.getRect)(this, '.van-slider').then(function (rect) { var vertical = _this.data.vertical; var delta = vertical ? _this.deltaY : _this.deltaX; @@ -84,11 +89,15 @@ var utils_1 = require("../common/utils"); }); }, onTouchEnd: function () { + var _this = this; if (this.data.disabled) return; - if (this.dragStatus === 'draging') { - this.updateValue(this.newValue, true); - this.$emit('drag-end'); + if (this.dragStatus === DRAG_STATUS.MOVING) { + this.dragStatus = DRAG_STATUS.END; + (0, utils_1.nextTick)(function () { + _this.updateValue(_this.newValue, true); + _this.$emit('drag-end'); + }); } }, onClick: function (event) { @@ -164,7 +173,7 @@ var utils_1 = require("../common/utils"); getOffsetWidth: function (current, min) { var scope = this.getScope(); // 避免最小值小于最小step时出现负数情况 - return "".concat(Math.max((current - min) * 100 / scope, 0), "%"); + return "".concat(Math.max(((current - min) * 100) / scope, 0), "%"); }, // 计算选中条的长度百分比 calcMainAxis: function () { diff --git a/lib/stepper/index.js b/lib/stepper/index.js index 409517b0..80f91faa 100644 --- a/lib/stepper/index.js +++ b/lib/stepper/index.js @@ -109,7 +109,6 @@ function equal(value1, value2) { }, onBlur: function (event) { var value = this.format(event.detail.value); - this.emitChange(value); this.$emit('blur', __assign(__assign({}, event.detail), { value: value })); }, // filter illegal characters diff --git a/lib/tabs/index.js b/lib/tabs/index.js index 625dde02..b9c22bdb 100644 --- a/lib/tabs/index.js +++ b/lib/tabs/index.js @@ -88,6 +88,7 @@ var relation_1 = require("../common/relation"); skipTransition: true, scrollWithAnimation: false, lineOffsetLeft: 0, + inited: false, }, mounted: function () { var _this = this; @@ -201,12 +202,13 @@ var relation_1 = require("../common/relation"); .reduce(function (prev, curr) { return prev + curr.width; }, 0); lineOffsetLeft += (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8); - _this.setData({ lineOffsetLeft: lineOffsetLeft }); + _this.setData({ lineOffsetLeft: lineOffsetLeft, inited: true }); _this.swiping = true; if (skipTransition) { - (0, utils_1.nextTick)(function () { + // waiting transition end + setTimeout(function () { _this.setData({ skipTransition: false }); - }); + }, _this.data.duration); } }); }, diff --git a/lib/tabs/index.wxml b/lib/tabs/index.wxml index f76dd63f..6fcb57f0 100644 --- a/lib/tabs/index.wxml +++ b/lib/tabs/index.wxml @@ -20,7 +20,7 @@ style="{{ color ? 'border-color: ' + color : '' }}" > - + ; diff --git a/lib/uploader/utils.js b/lib/uploader/utils.js index 96291b0c..be93a9a5 100644 --- a/lib/uploader/utils.js +++ b/lib/uploader/utils.js @@ -55,7 +55,7 @@ function formatFile(res) { return res.tempFiles.map(function (item) { return (__assign(__assign({}, (0, utils_1.pickExclude)(item, ['path'])), { url: item.path })); }); } function chooseFile(_a) { - var accept = _a.accept, multiple = _a.multiple, capture = _a.capture, compressed = _a.compressed, maxDuration = _a.maxDuration, sizeType = _a.sizeType, camera = _a.camera, maxCount = _a.maxCount; + var accept = _a.accept, multiple = _a.multiple, capture = _a.capture, compressed = _a.compressed, maxDuration = _a.maxDuration, sizeType = _a.sizeType, camera = _a.camera, maxCount = _a.maxCount, mediaType = _a.mediaType; return new Promise(function (resolve, reject) { switch (accept) { case 'image': @@ -70,6 +70,7 @@ function chooseFile(_a) { case 'media': wx.chooseMedia({ count: multiple ? Math.min(maxCount, 9) : 1, + mediaType: mediaType, sourceType: capture, maxDuration: maxDuration, sizeType: sizeType,