我试图在没有轮询或使用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())。
示例:https://codepen.io/Darksoulsong/pen/rwOQLo
添加新框,滚动视口,添加更多内容,并注意矩形值不会更新。