Skip to content

Commit

Permalink
fix: 调整visible逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed Apr 3, 2024
1 parent a4f3d03 commit 8306617
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Arc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export interface ArcGuideProps extends GuideProps {
}

export default (props: ArcGuideProps) => {
const { theme = {} } = props;
const { theme = {}, visible = true } = props;
const { coord, points, style, animation } = deepMix({ ...theme.line }, props);
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y));
if(checkNaN) return null;
if(checkNaN || !visible) return null;

const start = points[0] || {};
const end = points[1] || {};
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const defaultProps: Omit<ImageGuideProps, "records"> = {

export default (props: ImageGuideProps, context) => {
const cfg = deepMix({}, defaultProps, props);
const { points, style, attrs, offsetX, offsetY, src, animation } = cfg;
const { points, style, attrs, offsetX, offsetY, src, animation, visible = true } = cfg;
const { x, y } = points[0] || {};
if(isNaN(x) || isNaN(y)) return null;
if(isNaN(x) || isNaN(y) || !visible) return null;

const { height = 0, width = 0 } = { ...attrs, ...style };
const heightNum = context.px2hd(height + 'px');
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export interface LineGuideProps extends GuideProps {
}

export default (props: LineGuideProps, context) => {
const { theme = {} } = props;
const { theme = {}, visible = true } = props;
const { points, style, offsetX, offsetY, animation } = deepMix({ ...theme.line }, props);
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y));
if(checkNaN) return;
if(checkNaN || !visible) return;

const { x: x1, y: y1 } = points[0] || {};
const { x: x2, y: y2 } = points[1] || {};
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Lottie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const defaultProps: Omit<LottieGuideProps, 'records'> = {

export default (props: LottieGuideProps, context) => {
const cfg = deepMix({}, defaultProps, props);
const { points, style, offsetX, offsetY, lottieJson, animation, options } = cfg;
const { points, style, offsetX, offsetY, lottieJson, animation, options, visible = true } = cfg;
const { x, y } = points[0] || {};
if(isNaN(x) || isNaN(y)) return null;
if(isNaN(x) || isNaN(y) || !visible) return null;

const { height = 0, width = 0 } = style;

Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Point.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export interface PointGuideProps extends GuideProps {
}

export default (props: PointGuideProps, context) => {
const { theme } = props;
const { theme, visible = true } = props;
const { points, style, offsetX, offsetY, animation } = deepMix({ ...theme.point }, props);
const { x, y } = points[0] || {};
if(isNaN(x) || isNaN(y)) return null;
if(isNaN(x) || isNaN(y) || !visible) return null;

const offsetXNum = context.px2hd(offsetX);
const offsetYNum = context.px2hd(offsetY);
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Rect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export interface RectGuideProps extends GuideProps {
}

export default (props: RectGuideProps) => {
const { theme = {} } = props;
const { theme = {}, visible = true } = props;
const { points, style, animation } = deepMix({ ...theme.rect }, props);
const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y));
if(checkNaN) return null;
if(checkNaN || !visible) return null;

const start = points[0] || {};
const end = points[1] || {};
Expand Down
3 changes: 2 additions & 1 deletion packages/f2/src/components/guide/views/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ export default class Tag extends Component<TagGuideProps> {
canvasHeight,
background,
textStyle,
visible = true
} = px2hd(cfg);
const { x, y } = points[0] || {};
if(isNaN(x) || isNaN(y)) return null;
if(isNaN(x) || isNaN(y) || !visible) return null;

const offsetXNum = context.px2hd(offsetX);
const offsetYNum = context.px2hd(offsetY);
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/guide/views/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export interface TextGuideProps extends GuideProps {
}

export default (props: TextGuideProps, context) => {
const { theme = {} } = props;
const { theme = {}, visible = true } = props;
const { points, style, offsetX, offsetY, content, animation } = deepMix({ ...theme.text }, props);
const { x, y } = points[0] || {};

if(isNaN(x) || isNaN(y)) return null;
if(isNaN(x) || isNaN(y) || !visible) return null;
const offsetXNum = context.px2hd(offsetX);
const offsetYNum = context.px2hd(offsetY);
const posX = x + (offsetXNum || 0);
Expand Down
3 changes: 1 addition & 2 deletions packages/f2/src/components/guide/withGuide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export default function<IProps extends GuideProps = GuideProps>(

render() {
const { props, context } = this;
const { coord, records = [], animation, chart, style, onClick, visible = true } = props;
if(!visible) return;
const { coord, records = [], animation, chart, style, onClick } = props;
const { width, height } = context;
const points = this.convertPoints(records);
const theme = this.getGuideTheme();
Expand Down

0 comments on commit 8306617

Please sign in to comment.