研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
blockly >WorkspaceSvg >scrollX
相对于工作区原点的当前水平滚动偏移量(以像素为单位)。
不妨考虑一个视图,以及在该视图下方移动的画布。当画布向右移动时,该值会变得更正,并且视图现在是“看到”画布左侧当画布向左移动时,该值会变得更负,视图现在是“看到”画布右侧
关于此值的令人困惑之处在于,它不包含且不得包含 绝对 Left 偏移。这是因为它用于计算 viewLeft 值。
viewLeft 相对于工作区原点(虽然采用像素单位)。工作区原点位于工作区的左上角(至少在启用该工作区时是如此)。它会从 blocklyDiv 的左上角移动,以免位于工具箱下方。
启用工作区后,viewLeft 和工作区原点位于相同的 X 位置。当画布在视图下方向右滑动时,该值 (scrollX) 会变得更为正,并且 viewLeft 会相对于工作区原点变得更负(将工作区原点想象为画布上的一个点随着画布移动而向右滑动)。
因此,如果 scrollX 包含 绝对 Left,这将在一定程度上“取消移位”工作区源。这意味着 viewLeft 将表示 blocklyDiv 的左边缘,而不是工作区的左边缘。
Signature:
scrollX: number;
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-28。
[null,null,["最后更新时间 (UTC):2024-08-28。"],[[["`scrollX` represents the horizontal scrolling offset of the workspace canvas in pixels, relative to the workspace origin."],["Positive `scrollX` values indicate the canvas has moved right, while negative values indicate it has moved left."],["`scrollX` does not include the absoluteLeft offset to ensure `viewLeft` represents the workspace's left edge, not the `blocklyDiv`'s."],["The workspace origin is the top-left corner of the workspace and is the reference point for `scrollX` and `viewLeft`."],["As the canvas moves right, `scrollX` increases and `viewLeft` decreases, reflecting the relative positions of the canvas and the workspace origin."]]],[]]