Skip to content

Commit c9905e3

Browse files
wang1212sz-pAlexzjthuiyu.zjtgithub-actions[bot]
authored
Release (#1916)
* fix: set dx dy when textBaseline change to middle (#1911) (#1912) * fix: add pointerEvents none (#1913) Co-authored-by: huiyu.zjt <[email protected]> * chore: add changeset * chore(release): bump version (#1914) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: sz-p <[email protected]> Co-authored-by: huiyu.zjt <[email protected]> Co-authored-by: huiyu.zjt <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent c17534b commit c9905e3

File tree

18 files changed

+165
-11
lines changed

18 files changed

+165
-11
lines changed

__tests__/demos/bugfix/1911.ts

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { Canvas, Text, Rect, CanvasEvent } from '@antv/g';
2+
import { Renderer as SVGRenderer } from '@antv/g-svg';
3+
4+
/**
5+
* @see https://github.com/antvis/G/issues/1911
6+
*/
7+
export async function issue_1911(context) {
8+
const { canvas, gui } = context;
9+
await canvas.ready;
10+
11+
canvas.setRenderer(new SVGRenderer());
12+
13+
const text = new Text({
14+
style: {
15+
x: 100,
16+
y: 100,
17+
text: '这是测试文本This is text',
18+
textBaseline: 'bottom',
19+
fontSize: 40,
20+
textAlign: 'left',
21+
fill: '#1890FF',
22+
stroke: '#F04864',
23+
lineWidth: 5,
24+
},
25+
});
26+
const textLine3 = new Text({
27+
style: {
28+
x: 100,
29+
y: 300,
30+
text: '这是测试文本2 This is text in line 3',
31+
textBaseline: 'bottom',
32+
wordWrap: true,
33+
wordWrapWidth: 360,
34+
fontSize: 40,
35+
textAlign: 'left',
36+
fill: '#1890FF',
37+
stroke: '#F04864',
38+
lineWidth: 5,
39+
},
40+
});
41+
const bounds = new Rect({
42+
style: {
43+
width: 0,
44+
height: 0,
45+
stroke: 'black',
46+
lineWidth: 2,
47+
},
48+
});
49+
const bounds1 = new Rect({
50+
style: {
51+
width: 0,
52+
height: 0,
53+
stroke: 'black',
54+
lineWidth: 2,
55+
},
56+
});
57+
canvas.appendChild(text);
58+
canvas.appendChild(textLine3);
59+
canvas.appendChild(bounds);
60+
canvas.appendChild(bounds1);
61+
62+
canvas.addEventListener(CanvasEvent.AFTER_RENDER, () => {
63+
const bounding = text.getBounds();
64+
const bounding1 = textLine3.getBounds();
65+
if (bounding) {
66+
const { center, halfExtents } = bounding;
67+
bounds.attr('width', halfExtents[0] * 2);
68+
bounds.attr('height', halfExtents[1] * 2);
69+
bounds.setPosition(
70+
center[0] - halfExtents[0],
71+
center[1] - halfExtents[1],
72+
);
73+
}
74+
if (bounding1) {
75+
const { center, halfExtents } = bounding1;
76+
bounds1.attr('width', halfExtents[0] * 2);
77+
bounds1.attr('height', halfExtents[1] * 2);
78+
bounds1.setPosition(
79+
center[0] - halfExtents[0],
80+
center[1] - halfExtents[1],
81+
);
82+
}
83+
});
84+
85+
const folder = gui.addFolder('textBaseline');
86+
const config = { textBaseline: 'bottom' };
87+
folder
88+
.add(config, 'textBaseline', ['top', 'middle', 'bottom'])
89+
.onChange((name) => {
90+
text.attr('textBaseline', name);
91+
textLine3.attr('textBaseline', name);
92+
});
93+
94+
const dxyFolder = folder.addFolder('dx, dy');
95+
const dxyConfig = { dx: 0, dy: 0 };
96+
dxyFolder.add(dxyConfig, 'dx', -100, 100).onChange((dx) => {
97+
text.attr('dx', dx);
98+
textLine3.attr('dx', dx);
99+
});
100+
dxyFolder.add(dxyConfig, 'dy', -100, 100).onChange((dy) => {
101+
text.attr('dy', dy);
102+
textLine3.attr('dy', dy);
103+
});
104+
}

__tests__/demos/bugfix/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export { issue_1760 } from './1760';
1111
export { issue_1176 } from './1176';
1212
export { issue_1882 } from './1882';
1313
export { issue_1906 } from './1906';
14+
export { issue_1911 } from './1911';
1415
export { textWordWrap } from './textWordWrap';
1516
export { group_with_stroke } from './group-with-stroke';
1617
export { switchRenderer } from './switch-renderer';

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.35
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ae62b41]
8+
- @antv/g-plugin-svg-renderer@2.2.17
9+
- @antv/g-plugin-svg-picker@2.0.35
10+
311
## 1.0.34
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.34",
3+
"version": "1.0.35",
44
"description": "A renderer implemented by SVG in mobile environment",
55
"keywords": [
66
"antv",

packages/g-plugin-a11y/CHANGELOG.md

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

3+
## 1.1.22
4+
5+
### Patch Changes
6+
7+
- ae62b41: fix: add pointerEvents none
8+
39
## 1.1.21
410

511
### Patch Changes

packages/g-plugin-a11y/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-a11y",
3-
"version": "1.1.21",
3+
"version": "1.1.22",
44
"description": "A G plugin for accessibility",
55
"keywords": [
66
"antv",

packages/g-plugin-a11y/src/AriaManager.ts

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class AriaManager {
9191
div.style.top = `${DIV_TOUCH_POS_X}px`;
9292
div.style.left = `${DIV_TOUCH_POS_Y}px`;
9393
div.style.zIndex = DIV_TOUCH_ZINDEX.toString();
94+
div.style.pointerEvents = 'none';
9495

9596
this.$container = div;
9697
this.$container.id = `${CLASSNAME_PREFIX}-mask`;

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.36
4+
5+
### Patch Changes
6+
7+
- @antv/g-svg@2.0.35
8+
39
## 2.0.35
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.35",
3+
"version": "2.0.36",
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.35
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ae62b41]
8+
- @antv/g-plugin-svg-renderer@2.2.17
9+
310
## 2.0.34
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.34",
3+
"version": "2.0.35",
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.2.17
4+
5+
### Patch Changes
6+
7+
- ae62b41: fix: set dx dy when textBaseline change to middle
8+
39
## 2.2.16
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.2.16",
3+
"version": "2.2.17",
44
"description": "A G plugin of renderer implementation with SVG",
55
"keywords": [
66
"antv",

packages/g-plugin-svg-renderer/src/shapes/paths/Text.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ export function updateTextElementAttribute(
4949

5050
const lineNum = lines.length;
5151

52-
let styleCSSText = '';
53-
if (dx !== 0 || dy !== 0) {
54-
styleCSSText += `transform:translate(${dx}px, ${dy}px);`;
55-
}
52+
let styleCSSText = `transform:translate(${dx}px, ${dy}px);`;
5653
if (textDecorationLine && textDecorationLine !== 'none') {
5754
// use CSS text-decoration since the implementation in SVG is not good enough
5855
styleCSSText += `text-decoration:${textDecorationLine} ${textDecorationStyle} ${textDecorationColor};`;
@@ -78,6 +75,8 @@ export function updateTextElementAttribute(
7875
'dy',
7976
textBaseline === 'bottom' ? `-${height / 2}px` : `${height / 2}px`,
8077
);
78+
} else {
79+
$el.setAttribute('dy', '0px');
8180
}
8281

8382
// <textPath> only support one line

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.35
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ae62b41]
8+
- @antv/g-plugin-svg-renderer@2.2.17
9+
- @antv/g-svg@2.0.35
10+
311
## 2.0.34
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.34",
3+
"version": "2.0.35",
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.35
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ae62b41]
8+
- @antv/g-plugin-svg-renderer@2.2.17
9+
- @antv/g-plugin-svg-picker@2.0.35
10+
311
## 2.0.34
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.34",
3+
"version": "2.0.35",
44
"description": "A renderer implemented by SVG",
55
"keywords": [
66
"antv",

0 commit comments

Comments
 (0)