blockly >实用程序 >样式 >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 布尔值 (可选)是否在容器中使元素居中。默认值为 false。

返回

坐标

容器的新滚动位置。