don't autofocus colorpicker input fields on small touch devices
This commit is contained in:
parent
71b2ab14a0
commit
326dc5fb86
|
@ -34,6 +34,8 @@ CodeMirror.defineExtension('colorpicker', function () {
|
||||||
const $hsl = {};
|
const $hsl = {};
|
||||||
const $hexLettercase = {};
|
const $hexLettercase = {};
|
||||||
|
|
||||||
|
const allowInputFocus = !('ontouchstart' in document) || window.innerHeight > 800;
|
||||||
|
|
||||||
const dragging = {
|
const dragging = {
|
||||||
saturationPointerPos: {x: 0, y: 0},
|
saturationPointerPos: {x: 0, y: 0},
|
||||||
hueKnobPos: 0,
|
hueKnobPos: 0,
|
||||||
|
@ -348,9 +350,9 @@ CodeMirror.defineExtension('colorpicker', function () {
|
||||||
const inputs = $inputs[currentFormat];
|
const inputs = $inputs[currentFormat];
|
||||||
const lastInput = inputs[inputs.length - 1];
|
const lastInput = inputs[inputs.length - 1];
|
||||||
if (which === 9 && shift && el === inputs[0]) {
|
if (which === 9 && shift && el === inputs[0]) {
|
||||||
lastInput.focus();
|
maybeFocus(lastInput);
|
||||||
} else if (which === 9 && !shift && el === lastInput) {
|
} else if (which === 9 && !shift && el === lastInput) {
|
||||||
inputs[0].focus();
|
maybeFocus(inputs[0]);
|
||||||
} else if (which !== 9 && !shift) {
|
} else if (which !== 9 && !shift) {
|
||||||
setFromFormatElement({shift: which === 33 || shift});
|
setFromFormatElement({shift: which === 33 || shift});
|
||||||
} else {
|
} else {
|
||||||
|
@ -456,7 +458,7 @@ CodeMirror.defineExtension('colorpicker', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$inputGroups[format].dataset.active = '';
|
$inputGroups[format].dataset.active = '';
|
||||||
$inputs[format][0].focus();
|
maybeFocus($inputs[format][0]);
|
||||||
currentFormat = format;
|
currentFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,6 +884,12 @@ CodeMirror.defineExtension('colorpicker', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function maybeFocus(el) {
|
||||||
|
if (allowInputFocus) {
|
||||||
|
el.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function focusNoScroll(el) {
|
function focusNoScroll(el) {
|
||||||
if (el) {
|
if (el) {
|
||||||
const {scrollY: y, scrollX: x} = window;
|
const {scrollY: y, scrollX: x} = window;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user