ensure max>=min to keep colorpicker in view

This commit is contained in:
tophf 2018-08-16 19:58:05 +03:00
parent adc165723c
commit 4bcdbb78b1

View File

@ -788,8 +788,8 @@
const maxTopUnobscured = options.top <= maxTop ? maxTop : options.top - height - 20;
const maxRight = window.innerWidth - width;
const maxRightUnobscured = options.left <= maxRight ? maxRight : options.left - width;
const left = constrain(0, maxRightUnobscured, options.left);
const top = constrain(0, maxTopUnobscured, options.top);
const left = constrain(0, Math.max(0, maxRightUnobscured), options.left);
const top = constrain(0, Math.max(0, maxTopUnobscured), options.top);
$root.style.setProperty('left', left + 'px', 'important');
$root.style.setProperty('top', top + 'px', 'important');
}