Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const normalizedOffsets = (offset) => {
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
return tmp;
}, {});
const normalizedOffsets = (offset) => {
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
const normalizedOffsets = (offset) => {
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
return tmp;
}, {});
}
// input specifies an offset per position
const normalizedOffsets = (offset) => {
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
return tmp;
}, {});
}
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
return tmp;
}, {});
}
// input specifies an offset per position
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
return tmp;
}, {});
}
// input specifies an offset per position
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset[anchor] || [0, 0]);
const normalizedOffsets = (offset) => {
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
const normalizedOffsets = (offset) => {
if (!offset) {
return normalizedOffsets(new Point(0, 0));
}
if (typeof offset === 'number') {
// input specifies a radius from which to calculate offsets at all positions
const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
return {
center: new Point(offset, offset),
top: new Point(0, offset),
bottom: new Point(0, -offset),
left: new Point(offset, 0),
right: new Point(-offset, 0),
'top-left': new Point(cornerOffset, cornerOffset),
'top-right': new Point(-cornerOffset, cornerOffset),
'bottom-left': new Point(cornerOffset, -cornerOffset),
'bottom-right': new Point(-cornerOffset, -cornerOffset),
};
}
if (isPointLike(offset)) {
// input specifies a single offset to be applied to all positions
return anchors.reduce((res, anchor) => {
const tmp = Object.assign({}, res);
tmp[anchor] = Point.convert(offset);
return tmp;