Skip to content

Commit 700b5fb

Browse files
committed
feat: 升级 G 到 6.0
1 parent 4f06561 commit 700b5fb

16 files changed

Lines changed: 62 additions & 67 deletions

File tree

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ module.exports = {
2929
},
3030
},
3131
},
32+
transformIgnorePatterns: ['/node_modules/(?!d3-color/)'],
3233
};

packages/f-engine/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"miniprogram": "dist",
88
"sideEffects": false,
99
"dependencies": {
10-
"@antv/g-gesture": "~2.2.0",
11-
"@antv/g-lite": "~1.2.0",
12-
"@antv/g-mobile-canvas": "~0.11.0",
13-
"@antv/g-mobile-canvas-element": "~0.8.0",
14-
"@antv/g-mobile-svg": "~0.10.0",
15-
"@antv/g-mobile-webgl": "~0.9.0",
16-
"@antv/g-web-animations-api": "~1.2.0",
10+
"@antv/g-gesture": "~3.0.0",
11+
"@antv/g-lite": "~2.0.0",
12+
"@antv/g-mobile-canvas": "~1.0.0",
13+
"@antv/g-mobile-canvas-element": "~1.0.0",
14+
"@antv/g-mobile-svg": "~1.0.0",
15+
"@antv/g-mobile-webgl": "~1.0.0",
16+
"@antv/g-web-animations-api": "~2.0.0",
1717
"@antv/util": "^3.0.6",
1818
"@babel/runtime": "^7.12.5",
1919
"eventemitter3": "^4.0.0",

packages/f-engine/src/canvas/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@ class Canvas<P extends CanvasProps = CanvasProps> {
294294
const layout = computeLayout(style);
295295
const { left, top } = layout;
296296
// 设置 container 的位置
297-
this.container.setAttribute('x', left);
298-
this.container.setAttribute('y', top);
297+
// this.container.setAttribute('x', left);
298+
// this.container.setAttribute('y', top);
299+
this.container.setAttribute('transform', `translate(${left}, ${top})`);
299300

300301
this.context = {
301302
...this.context,

packages/f-engine/src/canvas/render/animation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ function morphShape(lastNode: VNode, nextNode: VNode, animator?: Animator) {
4949
const startStyle = {
5050
...lastStyle,
5151
...start,
52-
path: lastPath,
52+
d: lastPath,
5353
};
5454
const endStyle = {
5555
...nextStyle,
5656
...end,
57-
path: nextPath,
57+
d: nextPath,
5858
};
5959

60-
const pathShape = createShape('path', { style: { ...startStyle, path: '' } });
60+
const pathShape = createShape('path', { style: { ...startStyle, d: '' } });
6161

6262
// 形变双方都有的属性才能动画
6363
const animateProperty = property
6464
.filter((key) => {
6565
return nextParsedStyle.hasOwnProperty(key) && lastParsedStyle.hasOwnProperty(key);
6666
})
67-
.concat('path');
67+
.concat(['d']);
6868

6969
animator.animate(pathShape, startStyle, endStyle, {
7070
...animationEffect,

packages/f-engine/src/canvas/render/createShape.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
DisplayObject,
1111
CSS,
1212
PropertySyntax,
13+
runtime,
1314
} from '@antv/g-lite';
1415
import { Arc, Marker, Sector, SmoothPolyline } from '../../shape';
1516
import Gesture from '../../gesture';
@@ -91,6 +92,9 @@ SECTOR_CSS_PROPERTY.forEach((property) => {
9192
CSS.registerProperty(property);
9293
});
9394

95+
// https://github.com/antvis/G/releases/tag/%40antv%2Fg%406.0.0
96+
runtime.enableCSSParsing = true;
97+
9498
function createShape(type: string, props) {
9599
if (!type) return null;
96100
const ShapeClass = getTag(type);
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
export default (layout) => {
22
const { left, top, width, height } = layout;
33
return {
4-
x: left,
5-
y: top,
4+
// x: left,
5+
// y: top,
66
width,
77
height,
8+
transform: `translate(${left}, ${top})`,
89
};
910
};

packages/f-engine/src/shape/arc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export class Arc extends Path {
6262
const { cx = 0, cy = 0, startAngle, endAngle, r, anticlockwise } = this.parsedStyle;
6363

6464
if (isNil(startAngle) || isNil(endAngle) || startAngle === endAngle || isNil(r) || r <= 0) {
65-
super.setAttribute('path', '');
65+
super.setAttribute('d', '');
6666
return;
6767
}
6868

6969
const path = this.createPath(cx, cy, deg2rad(startAngle), deg2rad(endAngle), r, anticlockwise);
70-
super.setAttribute('path', path);
70+
super.setAttribute('d', path);
7171
}
7272

7373
private createPath(

packages/f-engine/src/shape/marker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ export class Marker extends Path {
6262

6363
const path = method(x, y, radius);
6464

65-
super.setAttribute('path', path);
65+
super.setAttribute('d', path);
6666
}
6767
}

packages/f-engine/src/shape/sector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class Sector extends Path {
135135
const { cx, cy, startAngle, endAngle, r, r0, radius, anticlockwise = false } = this.parsedStyle;
136136

137137
if (isNil(startAngle) || isNil(endAngle) || startAngle === endAngle || isNil(r) || r <= 0) {
138-
super.setAttribute('path', '');
138+
super.setAttribute('d', '');
139139
return;
140140
}
141141

@@ -149,7 +149,7 @@ export class Sector extends Path {
149149
radius ? radius : [0, 0, 0, 0],
150150
anticlockwise,
151151
);
152-
super.setAttribute('path', path);
152+
super.setAttribute('d', path);
153153
}
154154

155155
private createPath(

packages/f-engine/src/shape/smoothPolyline.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class SmoothPolyline extends Path {
3838
};
3939
}),
4040
false,
41-
constaint
41+
constaint,
4242
);
4343

4444
for (let i = 0, n = sps.length; i < n; i++) {
@@ -82,6 +82,6 @@ export class SmoothPolyline extends Path {
8282
}
8383
d.push(['L', pos[l][0], pos[l][1]]);
8484
}
85-
super.setAttribute('path', d);
85+
super.setAttribute('d', d);
8686
}
8787
}

0 commit comments

Comments
 (0)