* @function * @memberof Popper.Utils * @argument {Object} data - The data object generated by `update` method * @argument {Boolean} shouldRound - If the offsets should be rounded at all * @returns {Object} The popper's position offsets rounded * * The tale of pixel-perfect positioning. It's st
(data, shouldRound)
| 4214 | |
| 4215 | |
| 4216 | function getRoundedOffsets(data, shouldRound) { |
| 4217 | var _data$offsets = data.offsets, |
| 4218 | popper = _data$offsets.popper, |
| 4219 | reference = _data$offsets.reference; |
| 4220 | var round = Math.round, |
| 4221 | floor = Math.floor; |
| 4222 | |
| 4223 | var noRound = function noRound(v) { |
| 4224 | return v; |
| 4225 | }; |
| 4226 | |
| 4227 | var referenceWidth = round(reference.width); |
| 4228 | var popperWidth = round(popper.width); |
| 4229 | var isVertical = ['left', 'right'].indexOf(data.placement) !== -1; |
| 4230 | var isVariation = data.placement.indexOf('-') !== -1; |
| 4231 | var sameWidthParity = referenceWidth % 2 === popperWidth % 2; |
| 4232 | var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1; |
| 4233 | var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor; |
| 4234 | var verticalToInteger = !shouldRound ? noRound : round; |
| 4235 | return { |
| 4236 | left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left), |
| 4237 | top: verticalToInteger(popper.top), |
| 4238 | bottom: verticalToInteger(popper.bottom), |
| 4239 | right: horizontalToInteger(popper.right) |
| 4240 | }; |
| 4241 | } |
| 4242 | |
| 4243 | var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent); |
| 4244 | /** |
no outgoing calls
no test coverage detected
searching dependent graphs…