el.getBoundingClientRect()上的MutationObserver用于检测屏幕上的元素位置

时间:2017-06-08 17:37:00

标签: javascript mutation-observers

我试图在没有轮询或使用private CGPath QuartzPath(NSBezierPath nsPath){ nint j, numElements; CGPath immutablePath = null; numElements = nsPath.ElementCount; if(numElements > 0){ CGPath path = new CGPath(); CGPoint[] points = new CGPoint[] { new CGPoint(0.0f, 0.0f),new CGPoint(0.0f, 0.0f),new CGPoint(0.0f, 0.0f) }; bool didClosePath = true; for (j = 0; j < numElements; j++){ switch (nsPath.ElementAt(j)){ case NSBezierPathElement.MoveTo: path.MoveToPoint(points[0].X, points[0].Y); break; case NSBezierPathElement.LineTo: path.AddLineToPoint(points[0].X, points[0].Y); didClosePath = false; break; case NSBezierPathElement.CurveTo: path.AddCurveToPoint(points[0].X, points[0].Y, points[1].X, points[1].Y, points[2].X, points[2].Y); didClosePath = false; break; case NSBezierPathElement.ClosePath: path.CloseSubpath(); didClosePath = true; break; } } if(!didClosePath){ path.CloseSubpath(); } immutablePath = path.Copy(); } return immutablePath; } 等事件的情况下检测DOM元素屏幕位置变化。 onscroll可以解决问题,但似乎它不适用于方法(例如getBoundingClientRect())。

这是准确的吗?如果没有,我如何使用MutationObserver来检测clientRect更改?

示例:https://codepen.io/Darksoulsong/pen/rwOQLo

添加新框,滚动视口,添加更多内容,并注意矩形值不会更新。

0 个答案:

没有答案