From 20a98ca6beaf4a59dffdc8014b903f514630d40f Mon Sep 17 00:00:00 2001 From: xiaoiver Date: Thu, 28 Mar 2024 20:22:10 +0800 Subject: [PATCH] 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] --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] --- __tests__/unit/dom/animation.timeline.spec.ts | 37 +++++++++++++++++++ .../web-animations-api/custom-easing.spec.ts | 14 +++++++ packages/g-mobile-svg/CHANGELOG.md | 8 ++++ packages/g-mobile-svg/package.json | 2 +- .../g-plugin-rough-svg-renderer/CHANGELOG.md | 6 +++ .../g-plugin-rough-svg-renderer/package.json | 2 +- packages/g-plugin-svg-picker/CHANGELOG.md | 7 ++++ packages/g-plugin-svg-picker/package.json | 2 +- packages/g-plugin-svg-renderer/CHANGELOG.md | 6 +++ packages/g-plugin-svg-renderer/package.json | 2 +- .../src/SVGRendererPlugin.ts | 6 ++- .../g-plugin-zdog-svg-renderer/CHANGELOG.md | 8 ++++ .../g-plugin-zdog-svg-renderer/package.json | 2 +- packages/g-svg/CHANGELOG.md | 8 ++++ packages/g-svg/package.json | 2 +- packages/g-web-animations-api/CHANGELOG.md | 6 +++ packages/g-web-animations-api/package.json | 2 +- .../src/utils/interpolation.ts | 4 +- packages/g/CHANGELOG.md | 7 ++++ packages/g/package.json | 2 +- packages/react-g/CHANGELOG.md | 6 +++ packages/react-g/package.json | 2 +- 22 files changed, 127 insertions(+), 14 deletions(-) diff --git a/__tests__/unit/dom/animation.timeline.spec.ts b/__tests__/unit/dom/animation.timeline.spec.ts index 3b3fd0ab7..178e98521 100644 --- a/__tests__/unit/dom/animation.timeline.spec.ts +++ b/__tests__/unit/dom/animation.timeline.spec.ts @@ -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); + }); }); diff --git a/__tests__/unit/web-animations-api/custom-easing.spec.ts b/__tests__/unit/web-animations-api/custom-easing.spec.ts index 661ea733c..d769ba9f5 100644 --- a/__tests__/unit/web-animations-api/custom-easing.spec.ts +++ b/__tests__/unit/web-animations-api/custom-easing.spec.ts @@ -1,6 +1,7 @@ import { convertToDash, EasingFunctions, + parseEasingFunction, } from '../../../packages/g-web-animations-api/src/utils'; describe('Custom easing utils', () => { @@ -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); + }); }); diff --git a/packages/g-mobile-svg/CHANGELOG.md b/packages/g-mobile-svg/CHANGELOG.md index e41bcb0d0..068c2c6cf 100644 --- a/packages/g-mobile-svg/CHANGELOG.md +++ b/packages/g-mobile-svg/CHANGELOG.md @@ -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 diff --git a/packages/g-mobile-svg/package.json b/packages/g-mobile-svg/package.json index 97d28714d..1638761b6 100644 --- a/packages/g-mobile-svg/package.json +++ b/packages/g-mobile-svg/package.json @@ -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", diff --git a/packages/g-plugin-rough-svg-renderer/CHANGELOG.md b/packages/g-plugin-rough-svg-renderer/CHANGELOG.md index add30fa64..d0df3ba0a 100644 --- a/packages/g-plugin-rough-svg-renderer/CHANGELOG.md +++ b/packages/g-plugin-rough-svg-renderer/CHANGELOG.md @@ -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 diff --git a/packages/g-plugin-rough-svg-renderer/package.json b/packages/g-plugin-rough-svg-renderer/package.json index 132ea6ee2..0b48069eb 100644 --- a/packages/g-plugin-rough-svg-renderer/package.json +++ b/packages/g-plugin-rough-svg-renderer/package.json @@ -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", diff --git a/packages/g-plugin-svg-picker/CHANGELOG.md b/packages/g-plugin-svg-picker/CHANGELOG.md index b96cc1e05..d1294cd91 100644 --- a/packages/g-plugin-svg-picker/CHANGELOG.md +++ b/packages/g-plugin-svg-picker/CHANGELOG.md @@ -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 diff --git a/packages/g-plugin-svg-picker/package.json b/packages/g-plugin-svg-picker/package.json index f2aafd5ee..53cd51811 100644 --- a/packages/g-plugin-svg-picker/package.json +++ b/packages/g-plugin-svg-picker/package.json @@ -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", diff --git a/packages/g-plugin-svg-renderer/CHANGELOG.md b/packages/g-plugin-svg-renderer/CHANGELOG.md index 2cdce0580..e59a83001 100644 --- a/packages/g-plugin-svg-renderer/CHANGELOG.md +++ b/packages/g-plugin-svg-renderer/CHANGELOG.md @@ -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 diff --git a/packages/g-plugin-svg-renderer/package.json b/packages/g-plugin-svg-renderer/package.json index dc110d013..7e1ec8d7a 100644 --- a/packages/g-plugin-svg-renderer/package.json +++ b/packages/g-plugin-svg-renderer/package.json @@ -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", diff --git a/packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts b/packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts index dcc02b603..eb7822a96 100644 --- a/packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts +++ b/packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts @@ -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) { diff --git a/packages/g-plugin-zdog-svg-renderer/CHANGELOG.md b/packages/g-plugin-zdog-svg-renderer/CHANGELOG.md index 49c3600ec..2d0a5b436 100644 --- a/packages/g-plugin-zdog-svg-renderer/CHANGELOG.md +++ b/packages/g-plugin-zdog-svg-renderer/CHANGELOG.md @@ -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 diff --git a/packages/g-plugin-zdog-svg-renderer/package.json b/packages/g-plugin-zdog-svg-renderer/package.json index cfab099e5..c47a5e2df 100644 --- a/packages/g-plugin-zdog-svg-renderer/package.json +++ b/packages/g-plugin-zdog-svg-renderer/package.json @@ -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", diff --git a/packages/g-svg/CHANGELOG.md b/packages/g-svg/CHANGELOG.md index a51ff8a78..7af3b9994 100644 --- a/packages/g-svg/CHANGELOG.md +++ b/packages/g-svg/CHANGELOG.md @@ -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 diff --git a/packages/g-svg/package.json b/packages/g-svg/package.json index a9ca3e5bf..bb82f8749 100644 --- a/packages/g-svg/package.json +++ b/packages/g-svg/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-svg", - "version": "2.0.1", + "version": "2.0.2", "description": "A renderer implemented by SVG", "keywords": [ "antv", diff --git a/packages/g-web-animations-api/CHANGELOG.md b/packages/g-web-animations-api/CHANGELOG.md index 013ba43af..2abbab80c 100644 --- a/packages/g-web-animations-api/CHANGELOG.md +++ b/packages/g-web-animations-api/CHANGELOG.md @@ -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 diff --git a/packages/g-web-animations-api/package.json b/packages/g-web-animations-api/package.json index 0bfc36e80..1258cafba 100644 --- a/packages/g-web-animations-api/package.json +++ b/packages/g-web-animations-api/package.json @@ -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", diff --git a/packages/g-web-animations-api/src/utils/interpolation.ts b/packages/g-web-animations-api/src/utils/interpolation.ts index a48e8bd80..c2732a391 100644 --- a/packages/g-web-animations-api/src/utils/interpolation.ts +++ b/packages/g-web-animations-api/src/utils/interpolation.ts @@ -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, diff --git a/packages/g/CHANGELOG.md b/packages/g/CHANGELOG.md index 82f1e892f..f505c2936 100644 --- a/packages/g/CHANGELOG.md +++ b/packages/g/CHANGELOG.md @@ -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 diff --git a/packages/g/package.json b/packages/g/package.json index 8ade566ad..236dee758 100644 --- a/packages/g/package.json +++ b/packages/g/package.json @@ -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", diff --git a/packages/react-g/CHANGELOG.md b/packages/react-g/CHANGELOG.md index 3fdc2a398..b11ec2500 100644 --- a/packages/react-g/CHANGELOG.md +++ b/packages/react-g/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/react-g +## 2.0.2 + +### Patch Changes + +- @antv/g@6.0.2 + ## 2.0.1 ### Patch Changes diff --git a/packages/react-g/package.json b/packages/react-g/package.json index 13454f85a..4a8f80246 100644 --- a/packages/react-g/package.json +++ b/packages/react-g/package.json @@ -1,6 +1,6 @@ { "name": "@antv/react-g", - "version": "2.0.1", + "version": "2.0.2", "description": "react render for @antv/g", "keywords": [ "react",