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

Release #1658

Merged
merged 2 commits into from
Mar 28, 2024
Merged

Release #1658

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions __tests__/unit/dom/animation.timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,41 @@ describe('Animation Timeline', () => {

expect(circle.style.opacity).toBe(0.5);
});

it('should use cubic-bezier correctly', async () => {
const circle = new Circle({
id: 'circle',
style: {
r: 100,
},
});

await canvas.ready;
canvas.appendChild(circle);

const animation = circle.animate([{ r: 0 }, { r: 100 }], {
duration: 500,
easing: 'cubic-bezier(0.05, 0.21, 0.26, 1.31)',
fill: 'forwards',
})!;

animation.pause();
animation.currentTime = 0;
expect(circle.style.r).toBe(0);

animation.currentTime = 250;
expect(circle.style.r).toBeCloseTo(98.24289047791895);

animation.currentTime = 275;
expect(circle.style.r).toBeCloseTo(100.96325609464722);

animation.currentTime = 400;
expect(circle.style.r).toBeCloseTo(105.24435426047445);

animation.currentTime = 450;
expect(circle.style.r).toBeCloseTo(103.43753135054527);

animation.currentTime = 500;
expect(circle.style.r).toBe(100);
});
});
14 changes: 14 additions & 0 deletions __tests__/unit/web-animations-api/custom-easing.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
convertToDash,
EasingFunctions,
parseEasingFunction,
} from '../../../packages/g-web-animations-api/src/utils';

describe('Custom easing utils', () => {
Expand All @@ -18,4 +19,17 @@ describe('Custom easing utils', () => {
}
});
});

it('should calc cubic-bezier correctly.', () => {
let f = parseEasingFunction('cubic-bezier(0, 0, 1, 0.5)');
expect(f(0)).toBe(0);
expect(f(0.5)).toBe(0.3125);
expect(f(1)).toBe(1);

f = parseEasingFunction('cubic-bezier(0.05, 0.21, 0.26, 1.31)');
expect(f(0)).toBe(0);
expect(f(0.5)).toBeCloseTo(0.9824289047791895);
expect(f(0.75)).toBeCloseTo(1.0546732024179284);
expect(f(1)).toBe(1);
});
});
8 changes: 8 additions & 0 deletions packages/g-mobile-svg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-mobile-svg

## 1.0.2

### Patch Changes

- Updated dependencies [6009d6f2]
- @antv/[email protected]
- @antv/[email protected]

## 1.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-mobile-svg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-mobile-svg",
"version": "1.0.1",
"version": "1.0.2",
"description": "A renderer implemented by SVG in mobile environment",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-rough-svg-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-rough-svg-renderer

## 2.0.2

### Patch Changes

- @antv/[email protected]

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-rough-svg-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-rough-svg-renderer",
"version": "2.0.1",
"version": "2.0.2",
"description": "A G plugin of renderer implementation with rough.js",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-plugin-svg-picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-plugin-svg-picker

## 2.0.2

### Patch Changes

- Updated dependencies [6009d6f2]
- @antv/[email protected]

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-svg-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-svg-picker",
"version": "2.0.1",
"version": "2.0.2",
"description": "A G plugin for picking in SVG",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-svg-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-svg-renderer

## 2.0.2

### Patch Changes

- 6009d6f2: Scaled local time should not be interpolated with easing function.

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-svg-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-svg-renderer",
"version": "2.0.1",
"version": "2.0.2",
"description": "A G plugin of renderer implementation with SVG",
"keywords": [
"antv",
Expand Down
6 changes: 4 additions & 2 deletions packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,14 @@ export class SVGRendererPlugin implements RenderingPlugin {
rts[5],
)},${numberToLongString(rts[12])},${numberToLongString(rts[13])})`;

$el.removeAttribute('transform');
if (matrix !== DEFAULT_VALUE_MAP.transform) {
if (matrix !== $el.getAttribute('transform')) {
// use proper precision avoiding too long string in `transform`
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
$el.setAttribute('transform', matrix);
}
if (matrix === DEFAULT_VALUE_MAP.transform) {
$el.removeAttribute('transform');
}
}

private applyAttributes(object: DisplayObject) {
Expand Down
8 changes: 8 additions & 0 deletions packages/g-plugin-zdog-svg-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-plugin-zdog-svg-renderer

## 2.0.2

### Patch Changes

- Updated dependencies [6009d6f2]
- @antv/[email protected]
- @antv/[email protected]

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-zdog-svg-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-zdog-svg-renderer",
"version": "2.0.1",
"version": "2.0.2",
"description": "A G plugin of renderer implementation with Zdog",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-svg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-svg

## 2.0.2

### Patch Changes

- Updated dependencies [6009d6f2]
- @antv/[email protected]
- @antv/[email protected]

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-svg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-svg",
"version": "2.0.1",
"version": "2.0.2",
"description": "A renderer implemented by SVG",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-web-animations-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-web-animations-api

## 2.0.2

### Patch Changes

- 6009d6f2: Scaled local time should not be interpolated with easing function.

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-web-animations-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-web-animations-api",
"version": "2.0.1",
"version": "2.0.2",
"description": "A simple implementation of Web Animations API.",
"keywords": [
"antv",
Expand Down
4 changes: 1 addition & 3 deletions packages/g-web-animations-api/src/utils/interpolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export function convertEffectInput(
const localDuration =
interpolation.endOffset - interpolation.startOffset;
const scaledLocalTime =
localDuration === 0
? 0
: interpolation.easingFunction(offsetFraction / localDuration);
localDuration === 0 ? 0 : offsetFraction / localDuration;
// apply updated attribute
target.setAttribute(
interpolation.property,
Expand Down
7 changes: 7 additions & 0 deletions packages/g/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g

## 6.0.2

### Patch Changes

- Updated dependencies [6009d6f2]
- @antv/[email protected]

## 6.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g",
"version": "6.0.1",
"version": "6.0.2",
"description": "A core module for rendering engine implements DOM API.",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/react-g/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/react-g

## 2.0.2

### Patch Changes

- @antv/[email protected]

## 2.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-g/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/react-g",
"version": "2.0.1",
"version": "2.0.2",
"description": "react render for @antv/g",
"keywords": [
"react",
Expand Down
Loading