2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-24 15:10:37 +03:00

修复timePicker 滚动样式

This commit is contained in:
mxie
2018-01-17 13:14:33 +08:00
parent 99451b71a6
commit dd9e90d840
+25 -4
View File
@@ -375,6 +375,21 @@ export default {
now.setMonth(now.getMonth() + flag, 1) now.setMonth(now.getMonth() + flag, 1)
this.now = now this.now = now
}, },
scrollIntoView(container, selected) {
if (!selected) {
container.scrollTop = 0
return
}
const top = selected.offsetTop
const bottom = selected.offsetTop + selected.offsetHeight
const viewRectTop = container.scrollTop
const viewRectBottom = viewRectTop + container.clientHeight
if (top < viewRectTop) {
container.scrollTop = top
} else if (bottom > viewRectBottom) {
container.scrollTop = bottom - container.clientHeight
}
},
selectDate(cell) { selectDate(cell) {
const classes = this.getDateClasses(cell) const classes = this.getDateClasses(cell)
if (classes.indexOf('disabled') !== -1) { if (classes.indexOf('disabled') !== -1) {
@@ -402,9 +417,9 @@ export default {
this.currentPanel = 'time' this.currentPanel = 'time'
this.$nextTick(() => { this.$nextTick(() => {
Array.prototype.forEach.call( Array.prototype.forEach.call(
this.$el.querySelectorAll('.cur-time'), this.$el.querySelectorAll('.mx-time-list-wrapper'),
function(el) { (el) => {
el.scrollIntoView() this.scrollIntoView(el, el.querySelector('.cur-time'))
} }
) )
}) })
@@ -490,6 +505,11 @@ export default {
float: right; float: right;
} }
.mx-calendar-content {
height: 224px;
overflow: hidden;
}
.mx-calendar-table { .mx-calendar-table {
width: 100%; width: 100%;
font-size: 12px; font-size: 12px;
@@ -543,7 +563,7 @@ export default {
.mx-calendar-month, .mx-calendar-month,
.mx-calendar-time { .mx-calendar-time {
width: 100%; width: 100%;
height: 224px; height: 100%;
padding: 7px 0; padding: 7px 0;
text-align: center; text-align: center;
} }
@@ -563,6 +583,7 @@ export default {
} }
.mx-time-list-wrapper { .mx-time-list-wrapper {
position: relative;
display: inline-block; display: inline-block;
width: 100%; width: 100%;
height: 100%; height: 100%;