feat(joint-core): originX/originY options for getFitToContentArea#3315
Closed
kumilingus wants to merge 1 commit into
Closed
feat(joint-core): originX/originY options for getFitToContentArea#3315kumilingus wants to merge 1 commit into
kumilingus wants to merge 1 commit into
Conversation
`getFitToContentArea` previously hard-anchored its grid at (0, 0): grid lines fell at `0, gridWidth, 2*gridWidth, …`. New `originX` / `originY` options (default `0`, paper-local coords) shift the anchor so grid lines land at `originX + n*gridWidth, originY + m*gridHeight` instead. Backward compatible — omitting the new opts reproduces today's behavior exactly. `paper.fitToContent` already forwards `opt` through, so it inherits the feature automatically. Tested via `paper.fitToContent()` with a few combinations of `allowNewOrigin` × non-zero origin. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Superseded — origin commit cherry-picked into PR #3312 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
paper.getFitToContentArea(and thereforepaper.fitToContent) hard-anchored its grid at(0, 0): grid lines landed at0, gridWidth, 2*gridWidth, ….New options
originX?: number,originY?: number(default0, paper-local coords) shift the grid anchor so lines land atoriginX + n*gridWidth, originY + m*gridHeightinstead. Backward compatible — omitting the opts reproduces today's behavior exactly.Implementation
Paper.mjs::getFitToContentArea(src/dia/Paper.mjs):opt.originX/opt.originY(default0).area.x/area.ybysx/sy, subtractoriginX * sx/originY * syso the existing grid math operates in origin-relative space.new Rect(-tx/sx + originX, -ty/sy + originY, …).Paper.fitToContentinherits the feature automatically via the existingoptforwarding.types/dia.d.ts(FitToContentOptions).allowNewOrigin: 'any', and non-zero origin withoutallowNewOrigin.Motivation
Consumers wanting multi-page layouts where the first page starts at a non-zero offset (e.g. a sheet preset that doesn't start at the origin) currently have no way to express it. Used by the companion
@joint/react-plusPaperScroller refactor that introducessheetX/sheetYprops.Test plan
yarn workspace @joint/core test-client— confirms new tests pass, no regressions.fitToContent/getFitToContentAreacallers behave identically whenoriginX/originYare omitted.🤖 Generated with Claude Code