diff --git a/dist/calendar/index.js b/dist/calendar/index.js index b5021107..fe42145b 100644 --- a/dist/calendar/index.js +++ b/dist/calendar/index.js @@ -106,6 +106,7 @@ VantComponent({ type: Number, value: 0, }, + readonly: Boolean, }, data: { subtitle: '', @@ -211,6 +212,9 @@ VantComponent({ this.$emit('closed'); }, onClickDay(event) { + if (this.data.readonly) { + return; + } const { date } = event.detail; const { type, currentDate, allowSameDay } = this.data; if (type === 'range') { diff --git a/dist/slider/index.js b/dist/slider/index.js index be5f0f39..2c9b1231 100644 --- a/dist/slider/index.js +++ b/dist/slider/index.js @@ -93,9 +93,10 @@ VantComponent({ const { min } = this.data; getRect(this, '.van-slider').then((rect) => { const { vertical } = this.data; + const touch = event.touches[0]; const delta = vertical - ? event.detail.y - rect.top - : event.detail.x - rect.left; + ? touch.clientY - rect.top + : touch.clientX - rect.left; const total = vertical ? rect.height : rect.width; const value = Number(min) + (delta / total) * this.getRange(); if (this.isRange(this.value)) { @@ -136,7 +137,7 @@ VantComponent({ this.setData({ wrapperStyle: ` background: ${this.data.inactiveColor || ''}; - ${mainAxis}: ${addUnit(this.data.barHeight) || ''}; + ${vertical ? 'width' : 'height'}: ${addUnit(this.data.barHeight) || ''}; `, barStyle: ` ${mainAxis}: ${this.calcMainAxis()}; diff --git a/lib/calendar/index.js b/lib/calendar/index.js index b75034bd..b5c3075c 100644 --- a/lib/calendar/index.js +++ b/lib/calendar/index.js @@ -120,6 +120,7 @@ var initialMaxDate = (function () { type: Number, value: 0, }, + readonly: Boolean, }, data: { subtitle: '', @@ -231,6 +232,9 @@ var initialMaxDate = (function () { this.$emit('closed'); }, onClickDay: function (event) { + if (this.data.readonly) { + return; + } var date = event.detail.date; var _a = this.data, type = _a.type, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay; if (type === 'range') { diff --git a/lib/slider/index.js b/lib/slider/index.js index 644b6394..1c307ab4 100644 --- a/lib/slider/index.js +++ b/lib/slider/index.js @@ -98,9 +98,10 @@ var utils_1 = require("../common/utils"); var min = this.data.min; (0, utils_1.getRect)(this, '.van-slider').then(function (rect) { var vertical = _this.data.vertical; + var touch = event.touches[0]; var delta = vertical - ? event.detail.y - rect.top - : event.detail.x - rect.left; + ? touch.clientY - rect.top + : touch.clientX - rect.left; var total = vertical ? rect.height : rect.width; var value = Number(min) + (delta / total) * _this.getRange(); if (_this.isRange(_this.value)) { @@ -140,7 +141,7 @@ var utils_1 = require("../common/utils"); var vertical = this.data.vertical; var mainAxis = vertical ? 'height' : 'width'; this.setData({ - wrapperStyle: "\n background: " + (this.data.inactiveColor || '') + ";\n " + mainAxis + ": " + ((0, utils_1.addUnit)(this.data.barHeight) || '') + ";\n ", + wrapperStyle: "\n background: " + (this.data.inactiveColor || '') + ";\n " + (vertical ? 'width' : 'height') + ": " + ((0, utils_1.addUnit)(this.data.barHeight) || '') + ";\n ", barStyle: "\n " + mainAxis + ": " + this.calcMainAxis() + ";\n left: " + (vertical ? 0 : this.calcOffset()) + ";\n top: " + (vertical ? this.calcOffset() : 0) + ";\n " + (drag ? 'transition: none;' : '') + "\n ", }); if (drag) {