mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
Merge pull request #619 from rglasser27/fix-scrolling-for-mobile
Fix an issue with mobile scrolling
This commit is contained in:
commit
63441fde6d
@ -1007,28 +1007,34 @@ var datetimepickerFactory = function ($) {
|
|||||||
.find('.xdsoft_select')
|
.find('.xdsoft_select')
|
||||||
.xdsoftScroller(options)
|
.xdsoftScroller(options)
|
||||||
.on('touchstart mousedown.xdsoft', function (event) {
|
.on('touchstart mousedown.xdsoft', function (event) {
|
||||||
|
this.touchmoved = false;
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
})
|
})
|
||||||
.on('touchstart mousedown.xdsoft', '.xdsoft_option', function () {
|
.on('touchmove', '.xdsoft_option', function () {
|
||||||
if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
|
this.touchmoved = true;
|
||||||
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
})
|
||||||
}
|
.on('touchend mousedown.xdsoft', '.xdsoft_option', function () {
|
||||||
|
if (!this.touchmoved) {
|
||||||
|
if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
|
||||||
|
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
||||||
|
}
|
||||||
|
|
||||||
var year = _xdsoft_datetime.currentTime.getFullYear();
|
var year = _xdsoft_datetime.currentTime.getFullYear();
|
||||||
if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
|
if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
|
||||||
_xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
|
_xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).parent().parent().hide();
|
$(this).parent().parent().hide();
|
||||||
|
|
||||||
datetimepicker.trigger('xchange.xdsoft');
|
datetimepicker.trigger('xchange.xdsoft');
|
||||||
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
|
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
|
||||||
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
|
if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
|
||||||
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1866,33 +1872,41 @@ var datetimepickerFactory = function ($) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
timebox
|
timebox
|
||||||
|
.on('touchstart', 'div', function (xdevent) {
|
||||||
|
this.touchmoved = false;
|
||||||
|
})
|
||||||
|
.on('touchmove', 'div', function (xdevent) {
|
||||||
|
this.touchmoved = true;
|
||||||
|
})
|
||||||
.on('touchend click.xdsoft', 'div', function (xdevent) {
|
.on('touchend click.xdsoft', 'div', function (xdevent) {
|
||||||
xdevent.stopPropagation();
|
if (!this.touchmoved) {
|
||||||
var $this = $(this),
|
xdevent.stopPropagation();
|
||||||
currentTime = _xdsoft_datetime.currentTime;
|
var $this = $(this),
|
||||||
|
currentTime = _xdsoft_datetime.currentTime;
|
||||||
|
|
||||||
if (currentTime === undefined || currentTime === null) {
|
if (currentTime === undefined || currentTime === null) {
|
||||||
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
||||||
currentTime = _xdsoft_datetime.currentTime;
|
currentTime = _xdsoft_datetime.currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this.hasClass('xdsoft_disabled')) {
|
if ($this.hasClass('xdsoft_disabled')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
currentTime.setHours($this.data('hour'));
|
currentTime.setHours($this.data('hour'));
|
||||||
currentTime.setMinutes($this.data('minute'));
|
currentTime.setMinutes($this.data('minute'));
|
||||||
datetimepicker.trigger('select.xdsoft', [currentTime]);
|
datetimepicker.trigger('select.xdsoft', [currentTime]);
|
||||||
|
|
||||||
datetimepicker.data('input').val(_xdsoft_datetime.str());
|
datetimepicker.data('input').val(_xdsoft_datetime.str());
|
||||||
|
|
||||||
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
|
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
|
||||||
options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
|
options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
|
||||||
}
|
}
|
||||||
datetimepicker.data('changed', true);
|
datetimepicker.data('changed', true);
|
||||||
datetimepicker.trigger('xchange.xdsoft');
|
datetimepicker.trigger('xchange.xdsoft');
|
||||||
datetimepicker.trigger('changedatetime.xdsoft');
|
datetimepicker.trigger('changedatetime.xdsoft');
|
||||||
if (options.inline !== true && options.closeOnTimeSelect === true) {
|
if (options.inline !== true && options.closeOnTimeSelect === true) {
|
||||||
datetimepicker.trigger('close.xdsoft');
|
datetimepicker.trigger('close.xdsoft');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user