"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useKeepSelectedTileInView = void 0;
var react_1 = require("react");
var useResizeEffect_1 = require("../../hooks/layout/useResizeEffect");
var scroll_1 = require("../../utils/scroll");
var tiles_1 = require("../../utils/tiles");
exports.useKeepSelectedTileInView = function (containerRef, selected) {
    react_1.useLayoutEffect(function () {
        if (!containerRef.current)
            return;
        var container = containerRef.current;
        var selectedTile = tiles_1.getTile(container, selected);
        scroll_1.scrollToCenter(container, selectedTile);
    }, [containerRef, selected]);
    useResizeEffect_1.useResizeEffect(containerRef, function () {
        if (!containerRef.current)
            return;
        scroll_1.scrollToCenter(containerRef.current, tiles_1.getTile(containerRef.current, selected), false);
    });
};
