@atlaskit/navigation-system
Version:
The latest navigation system for Atlassian apps.
18 lines (16 loc) • 890 B
JavaScript
export var getWidthFromDragLocation = function getWidthFromDragLocation(_ref) {
var initialWidth = _ref.initialWidth,
location = _ref.location,
initialClientX = _ref.initialClientX,
direction = _ref.direction,
position = _ref.position;
var diffX = location.current.input.clientX - initialClientX;
// Resize line is positioned at the inline-end (right) of the element.
// If the direction is left-to-right, the width will increase when the mouse is moved to the right, and vice versa.
if (position === 'end') {
return direction === 'ltr' ? initialWidth + diffX : initialWidth - diffX;
}
// Resize line is positioned at the inline-start (left) of the element.
// If the direction is left-to-right, the width will decrease when the mouse is moved to the right, and vice versa.
return direction === 'ltr' ? initialWidth - diffX : initialWidth + diffX;
};