blockly > utils > style > getContainerOffsetToScrollInto

utils.style.getContainerOffsetToScrollInto() 函数

使用最小距离计算 container 的滚动位置,使给定 element 的内容和边框可见。如果元素大于容器,则其左上角会尽可能靠近容器的左上角。从 Closure 的 goog.style.getContainerOffsetToScrollInto 中复制

Signature:

export declare function getContainerOffsetToScrollInto(element: Element, container: Element, opt_center?: boolean): Coordinate;

参数

参数 类型 说明
元素 元素 要显示的元素。
容器 元素 要滚动的容器。如果未设置,系统将使用文档滚动元素。
opt_center boolean (可选)是否将元素居中放置在容器中。默认值为 false。

返回

坐标

容器的新滚动位置。