Skip to content

Commit

Permalink
Release (#1658)
Browse files Browse the repository at this point in the history
* fix: scaled local time should not be interpolated with easing function (#1656)

* fix: scaled local time should not be interpolated with easing function #1623

* chore: commit changeset

* chore(release): bump version (#1657)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent 494aedc commit 20a98ca
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 14 deletions.
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/g-plugin-svg-renderer@2.0.2
- @antv/g-plugin-svg-picker@2.0.2

## 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/g-svg@2.0.2

## 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/g-plugin-svg-renderer@2.0.2

## 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/g-plugin-svg-renderer@2.0.2
- @antv/g-svg@2.0.2

## 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/g-plugin-svg-renderer@2.0.2
- @antv/g-plugin-svg-picker@2.0.2

## 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/g-web-animations-api@2.0.2

## 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/g@6.0.2

## 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

0 comments on commit 20a98ca

Please sign in to comment.