Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define default init animation logic to each annotation element #863

Merged
merged 7 commits into from
May 9, 2023
Merged
Prev Previous commit
Next Next commit
CC duplications
  • Loading branch information
stockiNail committed Mar 8, 2023
commit bcb83108281e0b2b9791ac27bca1eae1122630b2
9 changes: 5 additions & 4 deletions src/helpers/helpers.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const isPercentString = (s) => typeof s === 'string' && s.endsWith('%');
const toPercent = (s) => parseFloat(s) / 100;
const toPositivePercent = (s) => clamp(toPercent(s), 0, 1);

const boxAppering = (x, y) => ({x, y, x2: x, y2: y, width: 0, height: 0});
const defaultInitAnimation = {
box: (properties) => ({x: properties.centerX, y: properties.centerY, x2: properties.centerX, y2: properties.centerY, width: 0, height: 0}),
box: (properties) => boxAppering(properties.centerX, properties.centerY),
ellipse: (properties) => ({centerX: properties.centerX, centerY: properties.centerX, radius: 0, width: 0, height: 0}),
label: (properties) => ({x: properties.centerX, y: properties.centerY, x2: properties.centerX, y2: properties.centerY, width: 0, height: 0}),
line: (properties) => ({x: properties.x, y: properties.y, x2: properties.x, y2: properties.y, width: 0, height: 0}),
label: (properties) => boxAppering(properties.centerX, properties.centerY),
line: (properties) => boxAppering(properties.x, properties.y),
point: (properties) => ({centerX: properties.centerX, centerY: properties.centerY, radius: 0, width: 0, height: 0}),
polygon: (properties) => ({x: properties.centerX, y: properties.centerY, x2: properties.centerX, y2: properties.centerY, width: 0, height: 0})
polygon: (properties) => boxAppering(properties.centerX, properties.centerY)
};

/**
Expand Down