Code cleanup con CodeMaid

This commit is contained in:
Samuele E. Locatelli
2020-09-11 12:45:52 +02:00
parent 831ad26bb0
commit 91ccb018af
293 changed files with 52598 additions and 50875 deletions
+28 -28
View File
@@ -18,33 +18,33 @@
* Only horizontal placement and left/right values need to be considered.
*/
export default function getRoundedOffsets(data, shouldRound) {
const { popper, reference } = data.offsets;
const { round, floor } = Math;
const noRound = v => v;
const referenceWidth = round(reference.width);
const popperWidth = round(popper.width);
const isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
const isVariation = data.placement.indexOf('-') !== -1;
const sameWidthParity = referenceWidth % 2 === popperWidth % 2;
const bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
const { popper, reference } = data.offsets;
const { round, floor } = Math;
const noRound = v => v;
const horizontalToInteger = !shouldRound
? noRound
: isVertical || isVariation || sameWidthParity
? round
: floor;
const verticalToInteger = !shouldRound ? noRound : round;
const referenceWidth = round(reference.width);
const popperWidth = round(popper.width);
return {
left: horizontalToInteger(
bothOddWidth && !isVariation && shouldRound
? popper.left - 1
: popper.left
),
top: verticalToInteger(popper.top),
bottom: verticalToInteger(popper.bottom),
right: horizontalToInteger(popper.right),
};
}
const isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
const isVariation = data.placement.indexOf('-') !== -1;
const sameWidthParity = referenceWidth % 2 === popperWidth % 2;
const bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
const horizontalToInteger = !shouldRound
? noRound
: isVertical || isVariation || sameWidthParity
? round
: floor;
const verticalToInteger = !shouldRound ? noRound : round;
return {
left: horizontalToInteger(
bothOddWidth && !isVariation && shouldRound
? popper.left - 1
: popper.left
),
top: verticalToInteger(popper.top),
bottom: verticalToInteger(popper.bottom),
right: horizontalToInteger(popper.right),
};
}