use toolbox::clamp() more
This commit is contained in:
parent
16edf57400
commit
576511e6eb
|
@ -1,4 +1,5 @@
|
|||
/* global $ $create animateElement focusAccessibility moveFocus */// dom.js
|
||||
/* global clamp */// toolbox.js
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
|
@ -84,10 +85,6 @@ messageBox.show = async ({
|
|||
messageBox._resolve = resolve;
|
||||
});
|
||||
|
||||
function clamp(value, min, max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
function initOwnListeners() {
|
||||
let listening = false;
|
||||
let offsetX = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* global $$ $ $create focusAccessibility getEventKeyName moveFocus */// dom.js
|
||||
/* global debounce */// toolbox.js
|
||||
/* global clamp debounce */// toolbox.js
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
const key = isSelect ? 'selectedIndex' : 'valueAsNumber';
|
||||
const old = el[key];
|
||||
const rawVal = old + Math.sign(event.deltaY) * (el.step || 1);
|
||||
el[key] = Math.max(el.min || 0, Math.min(el.max || el.length - 1, rawVal));
|
||||
el[key] = clamp(rawVal, el.min || 0, el.max || el.length - 1);
|
||||
if (el[key] !== old) {
|
||||
el.dispatchEvent(new Event('change', {bubbles: true}));
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
OPERA
|
||||
URLS
|
||||
capitalize
|
||||
clamp
|
||||
ignoreChromeError
|
||||
openURL
|
||||
*/// toolbox.js
|
||||
|
@ -288,7 +289,7 @@ function enforceInputRange(element) {
|
|||
if (type === 'input' && element.checkValidity()) {
|
||||
doNotify();
|
||||
} else if (type === 'change' && !element.checkValidity()) {
|
||||
element.value = Math.max(min, Math.min(max, Number(element.value)));
|
||||
element.value = clamp(Number(element.value), min, max);
|
||||
doNotify();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
FIREFOX
|
||||
URLS
|
||||
capitalize
|
||||
clamp
|
||||
getActiveTab
|
||||
isEmptyObj
|
||||
*/// toolbox.js
|
||||
|
@ -66,7 +67,7 @@ function onRuntimeMessage(msg) {
|
|||
|
||||
function setPopupWidth(_key, width) {
|
||||
document.body.style.width =
|
||||
Math.max(200, Math.min(800, width)) + 'px';
|
||||
clamp(width, 200, 800) + 'px';
|
||||
}
|
||||
|
||||
function toggleSideBorders(_key, state) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user