@helpscout/hsds-react
Version:
React component library for Help Scout's Design System
31 lines (25 loc) • 879 B
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.scrollIntoView = void 0;
var _lodash = _interopRequireDefault(require("lodash.isnil"));
var _computeScrollIntoView = _interopRequireDefault(require("./computeScrollIntoView.lib"));
/* istanbul ignore file */
// Source
// https://github.com/paypal/downshift/blob/master/src/utils.js#L25
var scrollIntoView = function scrollIntoView(node, rootNode) {
if ((0, _lodash.default)(node)) return;
var actions = (0, _computeScrollIntoView.default)(node, {
boundary: rootNode,
block: 'nearest',
scrollMode: 'if-needed'
});
actions.forEach(function (_ref) {
var el = _ref.el,
top = _ref.top,
left = _ref.left;
el.scrollTop = top;
el.scrollLeft = left;
});
};
exports.scrollIntoView = scrollIntoView;
;