Skip to content

Commit b2bee66

Browse files
tangying1027xuying.xu
andauthored
fix: guide超出范围不显示 (#1944)
Co-authored-by: xuying.xu <xuying.xu@alibaba-inc.com>
1 parent 860b339 commit b2bee66

File tree

9 files changed

+17
-5
lines changed

9 files changed

+17
-5
lines changed

packages/f2/src/components/guide/views/Arc.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export interface ArcGuideProps extends GuideProps {
1111
export default (props: ArcGuideProps) => {
1212
const { theme = {} } = props;
1313
const { coord, points, style, animation } = deepMix({ ...theme.line }, props);
14+
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y));
15+
if(checkNaN) return null;
1416

1517
const start = points[0] || {};
1618
const end = points[1] || {};

packages/f2/src/components/guide/views/Image.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export default (props: ImageGuideProps, context) => {
2222
const cfg = deepMix({}, defaultProps, props);
2323
const { points, style, attrs, offsetX, offsetY, src, animation } = cfg;
2424
const { x, y } = points[0] || {};
25+
if(isNaN(x) || isNaN(y)) return null;
26+
2527
const { height = 0, width = 0 } = { ...attrs, ...style };
2628
const heightNum = context.px2hd(height + 'px');
2729
const widthNum = context.px2hd(width + 'px');

packages/f2/src/components/guide/views/Line.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export interface LineGuideProps extends GuideProps {
1313
export default (props: LineGuideProps, context) => {
1414
const { theme = {} } = props;
1515
const { points, style, offsetX, offsetY, animation } = deepMix({ ...theme.line }, props);
16+
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y));
17+
if(checkNaN) return;
18+
1619
const { x: x1, y: y1 } = points[0] || {};
1720
const { x: x2, y: y2 } = points[1] || {};
1821

packages/f2/src/components/guide/views/Lottie.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export default (props: LottieGuideProps, context) => {
2828
const cfg = deepMix({}, defaultProps, props);
2929
const { points, style, offsetX, offsetY, lottieJson, animation, options } = cfg;
3030
const { x, y } = points[0] || {};
31+
if(isNaN(x) || isNaN(y)) return null;
32+
3133
const { height = 0, width = 0 } = style;
3234

3335
const offsetXNum = context.px2hd(offsetX);

packages/f2/src/components/guide/views/Point.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default (props: PointGuideProps, context) => {
1414
const { theme } = props;
1515
const { points, style, offsetX, offsetY, animation } = deepMix({ ...theme.point }, props);
1616
const { x, y } = points[0] || {};
17-
17+
if(isNaN(x) || isNaN(y)) return null;
18+
1819
const offsetXNum = context.px2hd(offsetX);
1920
const offsetYNum = context.px2hd(offsetY);
2021
const posX = x + (offsetXNum || 0);

packages/f2/src/components/guide/views/Rect.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export interface RectGuideProps extends GuideProps {
1111
export default (props: RectGuideProps) => {
1212
const { theme = {} } = props;
1313
const { points, style, animation } = deepMix({ ...theme.rect }, props);
14-
14+
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y));
15+
if(checkNaN) return null;
16+
1517
const start = points[0] || {};
1618
const end = points[1] || {};
1719

packages/f2/src/components/guide/views/Tag.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ export default class Tag extends Component<TagGuideProps> {
9595
textStyle,
9696
} = px2hd(cfg);
9797
const { x, y } = points[0] || {};
98-
98+
if(isNaN(x) || isNaN(y)) return null;
99+
99100
const offsetXNum = context.px2hd(offsetX);
100101
const offsetYNum = context.px2hd(offsetY);
101102
let posX = x + (offsetXNum || 0);

packages/f2/src/components/guide/views/Text.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default (props: TextGuideProps, context) => {
1616
const { points, style, offsetX, offsetY, content, animation } = deepMix({ ...theme.text }, props);
1717
const { x, y } = points[0] || {};
1818

19+
if(isNaN(x) || isNaN(y)) return null;
1920
const offsetXNum = context.px2hd(offsetX);
2021
const offsetYNum = context.px2hd(offsetY);
2122
const posX = x + (offsetXNum || 0);

packages/f2/src/components/guide/withGuide.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ export default function<IProps extends GuideProps = GuideProps>(
8181
const { width, height } = context;
8282
const points = this.convertPoints(records);
8383
const theme = this.getGuideTheme();
84-
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y))
85-
if(checkNaN) return;
8684

8785
return (
8886
<group

0 commit comments

Comments
 (0)