Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected layoutChildView(childView: View): void {
if (RenderView.is(childView)) {
let bounds = this._bounds;
let anchor = this._anchor;
const x = bounds.x;
const y = bounds.y;
if (bounds.x !== 0 || bounds.y !== 0) {
// transform bounds into layer coordinates
const width = bounds.width;
const height = bounds.height;
bounds = new BoxR2(0, 0, width, height);
}
if (x !== 0 || y !== 0) {
// transform anchor into layer coordinates
anchor = new PointR2(anchor.x - x, anchor.y - y);
}
childView.setBounds(bounds);
childView.setAnchor(anchor);
}
}
protected layoutChildView(childView: View): void {
if (RenderView.is(childView)) {
let bounds = this._bounds;
let anchor = this._anchor;
const x = bounds.x;
const y = bounds.y;
if (bounds.x !== 0 || bounds.y !== 0) {
// transform bounds into layer coordinates
const width = bounds.width;
const height = bounds.height;
bounds = new BoxR2(0, 0, width, height);
}
if (x !== 0 || y !== 0) {
// transform anchor into layer coordinates
anchor = new PointR2(anchor.x - x, anchor.y - y);
}
childView.setBounds(bounds);
childView.setAnchor(anchor);
}
}
for (let i = 0; i < n; i += 1) {
const coord = coords[i].value!;
const point = projection.project(coord);
points[i] = point;
cx += point.x;
cy += point.y;
invalid = invalid || !isFinite(point.x) || !isFinite(point.y);
xMin = Math.min(xMin, point.x);
yMin = Math.min(yMin, point.y);
xMax = Math.max(point.x, xMax);
yMax = Math.max(point.y, yMax);
}
cx /= n;
cy /= n;
if (!invalid) {
hitBounds = new BoxR2(xMin, yMin, xMax, yMax);
}
}
this._hitBounds = hitBounds;
this.setAnchor(new PointR2(cx, cy));
}
protected willSetBounds(bounds: BoxR2): BoxR2 | void {
const newBounds = super.willSetBounds(bounds);
if (newBounds instanceof BoxR2) {
bounds = newBounds;
}
const xMin = Math.round(bounds.xMin);
const yMin = Math.round(bounds.yMin);
const xMax = Math.round(bounds.xMax);
const yMax = Math.round(bounds.yMax);
return new BoxR2(xMin, yMin, xMax, yMax);
}
protected willSetBounds(bounds: BoxR2): BoxR2 | void {
const newBounds = super.willSetBounds(bounds);
if (newBounds instanceof BoxR2) {
bounds = newBounds;
}
const xMin = Math.round(bounds.xMin);
const yMin = Math.round(bounds.yMin);
const xMax = Math.round(bounds.xMax);
const yMax = Math.round(bounds.yMax);
return new BoxR2(xMin, yMin, xMax, yMax);
}