- ${input}
-
+
+
-
-
-
+
diff --git a/src/picker/date.wc b/src/picker/date.wc
index b871687..62b4b20 100644
--- a/src/picker/date.wc
+++ b/src/picker/date.wc
@@ -601,25 +601,15 @@ export default class DatePicker {
break
case 'max-date':
- if (val) {
- let tmp = new Date(val)
- if (tmp.getFullYear()) {
- this.props.max = {
- year: tmp.getFullYear(),
- month: tmp.getMonth(),
- day: tmp.getDate()
- }
- this._renderCalendar()
- }
- }
- this.removeAttribute('max-date')
- break
-
case 'min-date':
if (val) {
+ let v = +val
+ if (v === v) {
+ val = v
+ }
let tmp = new Date(val)
if (tmp.getFullYear()) {
- this.props.min = {
+ this.props[name.slice(0, 3)] = {
year: tmp.getFullYear(),
month: tmp.getMonth(),
day: tmp.getDate()
@@ -627,7 +617,7 @@ export default class DatePicker {
this._renderCalendar()
}
}
- this.removeAttribute('min-date')
+ this.removeAttribute(name)
break
case 'value':
diff --git a/src/scroll/index.wc b/src/scroll/index.wc
index b57d45d..444f22a 100644
--- a/src/scroll/index.wc
+++ b/src/scroll/index.wc
@@ -81,9 +81,7 @@ const IS_FF = !!window.sidebar
/* */
export default class Scroll {
- props = {
- v: ''
- }
+ props = {}
constructor() {
/* render */
this.__BOX__ = this.root.children[1]
@@ -91,6 +89,53 @@ export default class Scroll {
this.__Y__ = this.root.children[3].children[0]
}
+ get scrollTop() {
+ return this.__BOX__.scrollTop
+ }
+
+ set scrollTop(n) {
+ // this.__BOX__.scrollTop
+ }
+
+ get scrollLeft() {
+ return this.__BOX__.scrollLeft
+ }
+
+ set scrollLeft(val) {
+ // this.__BOX__.scrollLeft
+ }
+
+ get scrollHeight() {
+ return this.__BOX__.scrollHeight
+ }
+
+ _fetchScrollX(moveX) {
+ var { sw, ow, xw, sh, oh, yh } = this.props
+
+ if (moveX < 0) {
+ moveX = 0
+ } else if (moveX > ow - xw) {
+ moveX = ow - xw
+ }
+ this.__BOX__.scrollLeft = (sw - ow) * (moveX / (ow - xw))
+ this.__X__.style.transform = `translateX(${moveX}px)`
+
+ return moveX
+ }
+
+ _fetchScrollY(moveY) {
+ var { sw, ow, xw, sh, oh, yh } = this.props
+
+ if (moveY < 0) {
+ moveY = 0
+ } else if (moveY > oh - yh) {
+ moveY = oh - yh
+ }
+ this.__BOX__.scrollTop = (sh - oh) * (moveY / (oh - yh))
+ this.__Y__.style.transform = `translateY(${moveY}px)`
+ return moveY
+ }
+
mounted() {
// 初始化滚动条的位置和长度
this._initFn = ev => {
@@ -187,28 +232,13 @@ export default class Scroll {
moveX,
moveY,
mousemoveFn = ev => {
- var { sw, ow, xw, sh, oh, yh, thumbY, thumbX } = this.props
-
+ var { thumbY, thumbX } = this.props
if (startX !== null) {
- moveX = thumbX + ev.pageX - startX
- if (moveX < 0) {
- moveX = 0
- } else if (moveX > ow - xw) {
- moveX = ow - xw
- }
- this.__BOX__.scrollLeft = (sw - ow) * (moveX / (ow - xw))
- this.__X__.style.transform = `translateX(${moveX}px)`
+ moveX = this._fetchScrollX(thumbX + ev.pageX - startX)
}
if (startY !== null) {
- moveY = thumbY + ev.pageY - startY
- if (moveY < 0) {
- moveY = 0
- } else if (moveY > oh - yh) {
- moveY = oh - yh
- }
- this.__BOX__.scrollTop = (sh - oh) * (moveY / (oh - yh))
- this.__Y__.style.transform = `translateY(${moveY}px)`
+ moveY = this._fetchScrollY(thumbY + ev.pageY - startY)
}
},
mouseupFn = ev => {