获取屏幕外对象的偏移量
我正在尝试获取不在屏幕上的对象的偏移位置。 例如, 我有一个显示两个 html 页面的卷轴,我想在不在当前屏幕上的第二页上画线。当我尝试获取偏移量时,它返回 NaN。
任何人都知道如何获取不在屏幕上的物体的位置?
I am trying to get offset position of an object which is not on screen.
For example,
I have a scroll which display two html pages, I want to draw lines on second page which is not on the curent screen. When i try to get offset it return me NaN.
Anyone have any idea how to get the positions of object which is not on screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道获取屏幕外对象的位置有任何问题。您只需要确保它被渲染即可。通常,问题在于您的元素设置为 display:none,在这种情况下,您的位置会得到 NaN。有两种解决方案:
如果这不能解决您的问题,请发布简化的代码来显示您的问题。
I don't know of any problems getting the position of an off-screen object. You just need to make sure it is rendered. Usually, the problem is that your element is set to display:none, in which case you get NaN for its position. There are two solutions:
Please post simplified code to show your problem if this does not solve your problem.