Skip to content

Commit

Permalink
feat: add style func && fix lottie xy (#1693)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangying1027 committed Jan 3, 2023
1 parent 7fae5e5 commit 5e22591
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/f2/src/components/guide/views/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export default (props: ImageGuideProps, context) => {
const posY = y + (offsetYNum || 0) - heightNum / 2;

return (
<group style={style}>
<group>
<image
attrs={{
style={{
...baseAttrs,
...attrs,
...style,
height: heightNum,
width: widthNum,
x: posX,
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 @@ -31,8 +31,8 @@ export default (props: LottieGuideProps, context) => {

const offsetXNum = context.px2hd(offsetX);
const offsetYNum = context.px2hd(offsetY);
const posX = x + (offsetXNum || 0) - height / 2;
const posY = y + (offsetYNum || 0) - width / 2;
const posX = x + (offsetXNum || 0) - width / 2;
const posY = y + (offsetYNum || 0) - height / 2;

return (
<Lottie
Expand Down
3 changes: 2 additions & 1 deletion packages/f2/src/components/guide/withGuide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default (View: ComponentType) => {

render() {
const { props, context, guideBBox } = this;
const { coord, records = [], animation, chart } = props;
const { coord, records = [], animation, chart, style } = props;
const { width, height } = context;
const points = this.convertPoints(records);
const theme = this.getGuideTheme();
Expand All @@ -135,6 +135,7 @@ export default (View: ComponentType) => {
canvasWidth={width}
canvasHeight={height}
guideBBox={guideBBox}
style={isFunction(style) ? style(points, chart) : style}
animation={isFunction(animation) ? animation(points, chart) : animation}
/>
);
Expand Down

0 comments on commit 5e22591

Please sign in to comment.