Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: custom render node offset NaN #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/example/components/doc-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function DocDemo() {
height={elementSize}
// @ts-ignore
render={({ scale, attrs }) => {
const width = attrs.style!.width as number;
const width = parseFloat((attrs?.style?.width ?? 0) as string);
const offset = (width - elementSize) / elementSize;
// 保持子节点的 scale 的稳定
const childScale = scale === 1 ? scale + offset : 1 + offset;
Expand Down
2 changes: 1 addition & 1 deletion packages/example/pages/docs/getting-started.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function MyComponent() {
width={elementSize}
height={elementSize}
render={({ scale, attrs }) => {
const width = attrs.style.width;
const width = parseFloat((attrs?.style?.width ?? 0) as string);
const offset = (width - elementSize) / elementSize;
const childScale = scale === 1 ? scale + offset : 1 + offset;

Expand Down
2 changes: 1 addition & 1 deletion packages/example/pages/docs/getting-started.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function MyComponent() {
width={elementSize}
height={elementSize}
render={({ scale, attrs }) => {
const width = attrs.style.width;
const width = parseFloat((attrs?.style?.width ?? 0) as string);
const offset = (width - elementSize) / elementSize;
const childScale = scale === 1 ? scale + offset : 1 + offset;

Expand Down