Fix bug: scrolling time div on touchscreens

On touchscreens, the default datetimepicker closes unexpectedly when trying to scroll on the time picker. This is because scrolling triggers touchend event, just like clicking. 

To fix, we use the touchmove event to determine that we are scrolling, not clicking, using a global variable.
This commit is contained in:
J3QQ4 2016-06-16 19:07:47 +08:00 committed by GitHub
parent c902770678
commit 24fe9b6bd7

View File

@ -593,6 +593,9 @@ var DateFormatter;
} }
}(function ($) { }(function ($) {
'use strict'; 'use strict';
var currentlyScrollingTimeDiv = false;
var default_options = { var default_options = {
i18n: { i18n: {
ar: { // Arabic ar: { // Arabic
@ -2410,8 +2413,13 @@ var DateFormatter;
}); });
timebox timebox
.on('touchmove', 'div', function () { currentlyScrollingTimeDiv = true; })
.on('touchend click.xdsoft', 'div', function (xdevent) { .on('touchend click.xdsoft', 'div', function (xdevent) {
xdevent.stopPropagation(); xdevent.stopPropagation();
if (currentlyScrollingTimeDiv) {
currentlyScrollingTimeDiv = false;
return;
}
var $this = $(this), var $this = $(this),
currentTime = _xdsoft_datetime.currentTime; currentTime = _xdsoft_datetime.currentTime;