Skip to content

Commit 20a98ca

Browse files
Release (#1658)
* 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>
1 parent 494aedc commit 20a98ca

File tree

22 files changed

+127
-14
lines changed

22 files changed

+127
-14
lines changed

__tests__/unit/dom/animation.timeline.spec.ts

+37
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,41 @@ describe('Animation Timeline', () => {
118118

119119
expect(circle.style.opacity).toBe(0.5);
120120
});
121+
122+
it('should use cubic-bezier correctly', async () => {
123+
const circle = new Circle({
124+
id: 'circle',
125+
style: {
126+
r: 100,
127+
},
128+
});
129+
130+
await canvas.ready;
131+
canvas.appendChild(circle);
132+
133+
const animation = circle.animate([{ r: 0 }, { r: 100 }], {
134+
duration: 500,
135+
easing: 'cubic-bezier(0.05, 0.21, 0.26, 1.31)',
136+
fill: 'forwards',
137+
})!;
138+
139+
animation.pause();
140+
animation.currentTime = 0;
141+
expect(circle.style.r).toBe(0);
142+
143+
animation.currentTime = 250;
144+
expect(circle.style.r).toBeCloseTo(98.24289047791895);
145+
146+
animation.currentTime = 275;
147+
expect(circle.style.r).toBeCloseTo(100.96325609464722);
148+
149+
animation.currentTime = 400;
150+
expect(circle.style.r).toBeCloseTo(105.24435426047445);
151+
152+
animation.currentTime = 450;
153+
expect(circle.style.r).toBeCloseTo(103.43753135054527);
154+
155+
animation.currentTime = 500;
156+
expect(circle.style.r).toBe(100);
157+
});
121158
});

__tests__/unit/web-animations-api/custom-easing.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
convertToDash,
33
EasingFunctions,
4+
parseEasingFunction,
45
} from '../../../packages/g-web-animations-api/src/utils';
56

67
describe('Custom easing utils', () => {
@@ -18,4 +19,17 @@ describe('Custom easing utils', () => {
1819
}
1920
});
2021
});
22+
23+
it('should calc cubic-bezier correctly.', () => {
24+
let f = parseEasingFunction('cubic-bezier(0, 0, 1, 0.5)');
25+
expect(f(0)).toBe(0);
26+
expect(f(0.5)).toBe(0.3125);
27+
expect(f(1)).toBe(1);
28+
29+
f = parseEasingFunction('cubic-bezier(0.05, 0.21, 0.26, 1.31)');
30+
expect(f(0)).toBe(0);
31+
expect(f(0.5)).toBeCloseTo(0.9824289047791895);
32+
expect(f(0.75)).toBeCloseTo(1.0546732024179284);
33+
expect(f(1)).toBe(1);
34+
});
2135
});

packages/g-mobile-svg/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @antv/g-mobile-svg
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [6009d6f2]
8+
- @antv/g-plugin-svg-renderer@2.0.2
9+
- @antv/g-plugin-svg-picker@2.0.2
10+
311
## 1.0.1
412

513
### Patch Changes

packages/g-mobile-svg/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-mobile-svg",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A renderer implemented by SVG in mobile environment",
55
"keywords": [
66
"antv",

packages/g-plugin-rough-svg-renderer/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-plugin-rough-svg-renderer
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- @antv/g-svg@2.0.2
8+
39
## 2.0.1
410

511
### Patch Changes

packages/g-plugin-rough-svg-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-rough-svg-renderer",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A G plugin of renderer implementation with rough.js",
55
"keywords": [
66
"antv",

packages/g-plugin-svg-picker/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-plugin-svg-picker
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [6009d6f2]
8+
- @antv/g-plugin-svg-renderer@2.0.2
9+
310
## 2.0.1
411

512
### Patch Changes

packages/g-plugin-svg-picker/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-svg-picker",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A G plugin for picking in SVG",
55
"keywords": [
66
"antv",

packages/g-plugin-svg-renderer/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-plugin-svg-renderer
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- 6009d6f2: Scaled local time should not be interpolated with easing function.
8+
39
## 2.0.1
410

511
### Patch Changes

packages/g-plugin-svg-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-svg-renderer",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A G plugin of renderer implementation with SVG",
55
"keywords": [
66
"antv",

packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,14 @@ export class SVGRendererPlugin implements RenderingPlugin {
442442
rts[5],
443443
)},${numberToLongString(rts[12])},${numberToLongString(rts[13])})`;
444444

445-
$el.removeAttribute('transform');
446-
if (matrix !== DEFAULT_VALUE_MAP.transform) {
445+
if (matrix !== $el.getAttribute('transform')) {
447446
// use proper precision avoiding too long string in `transform`
448447
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
449448
$el.setAttribute('transform', matrix);
450449
}
450+
if (matrix === DEFAULT_VALUE_MAP.transform) {
451+
$el.removeAttribute('transform');
452+
}
451453
}
452454

453455
private applyAttributes(object: DisplayObject) {

packages/g-plugin-zdog-svg-renderer/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @antv/g-plugin-zdog-svg-renderer
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [6009d6f2]
8+
- @antv/g-plugin-svg-renderer@2.0.2
9+
- @antv/g-svg@2.0.2
10+
311
## 2.0.1
412

513
### Patch Changes

packages/g-plugin-zdog-svg-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-zdog-svg-renderer",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A G plugin of renderer implementation with Zdog",
55
"keywords": [
66
"antv",

packages/g-svg/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @antv/g-svg
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [6009d6f2]
8+
- @antv/g-plugin-svg-renderer@2.0.2
9+
- @antv/g-plugin-svg-picker@2.0.2
10+
311
## 2.0.1
412

513
### Patch Changes

packages/g-svg/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-svg",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A renderer implemented by SVG",
55
"keywords": [
66
"antv",

packages/g-web-animations-api/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-web-animations-api
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- 6009d6f2: Scaled local time should not be interpolated with easing function.
8+
39
## 2.0.1
410

511
### Patch Changes

packages/g-web-animations-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-web-animations-api",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A simple implementation of Web Animations API.",
55
"keywords": [
66
"antv",

packages/g-web-animations-api/src/utils/interpolation.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export function convertEffectInput(
3737
const localDuration =
3838
interpolation.endOffset - interpolation.startOffset;
3939
const scaledLocalTime =
40-
localDuration === 0
41-
? 0
42-
: interpolation.easingFunction(offsetFraction / localDuration);
40+
localDuration === 0 ? 0 : offsetFraction / localDuration;
4341
// apply updated attribute
4442
target.setAttribute(
4543
interpolation.property,

packages/g/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g
22

3+
## 6.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [6009d6f2]
8+
- @antv/g-web-animations-api@2.0.2
9+
310
## 6.0.1
411

512
### Patch Changes

packages/g/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g",
3-
"version": "6.0.1",
3+
"version": "6.0.2",
44
"description": "A core module for rendering engine implements DOM API.",
55
"keywords": [
66
"antv",

packages/react-g/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/react-g
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- @antv/g@6.0.2
8+
39
## 2.0.1
410

511
### Patch Changes

packages/react-g/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/react-g",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "react render for @antv/g",
55
"keywords": [
66
"react",

0 commit comments

Comments
 (0)