UNPKG

@atlaskit/navigation-system

Version:

The latest navigation system for Atlassian apps.

24 lines (21 loc) • 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWidthFromDragLocation = void 0; var getWidthFromDragLocation = exports.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; };