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

feat(cropper-selection): uses getAdjustedSizesKeepArea() for aspectRatio calculation #1164

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

NamesMT
Copy link

@NamesMT NamesMT commented Apr 21, 2024

Reopen of #1162

Previously we grow the width/height to fit with the new aspect-ratio.

This PR changes the calculation: now we changes both the width and height while keeping the original area, which in theory would fit a better UX, especially when take in account of (#1163 aspect-ratio reactivity)

Without this PR, #1163 would behave as follow: the selection area being grown out of view when input changes, especially for dynamic user inputted usage.

Summary

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of the default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)
There is a behavior change, is breaking.

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated
  • Related tests have been updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

…Ratio calculation

This prevents the selection area being grown out of view when input changes, especially for dynamic user inputted usage
@NamesMT
Copy link
Author

NamesMT commented Apr 21, 2024

If #1163 is accepted do note that there would be now a code line different in this PR that needs to be resolved.

For the tests, please help me work on it,
Currently something is incompatible on my local machine and I get error when running test:
Gotta go now can't investigate on this.

> [email protected] test
> jest

Error: Cannot find module './lib/stringify'
Require stack:
- /home/oss/cropperjs/node_modules/braces/index.js
- /home/oss/cropperjs/node_modules/micromatch/index.js
- /home/oss/cropperjs/node_modules/jest-haste-map/build/watchers/common.js
- /home/oss/cropperjs/node_modules/jest-haste-map/build/watchers/NodeWatcher.js
- /home/oss/cropperjs/node_modules/jest-haste-map/build/index.js
- /home/oss/cropperjs/node_modules/jest-runtime/build/index.js
- /home/oss/cropperjs/node_modules/@jest/core/build/cli/index.js
- /home/oss/cropperjs/node_modules/@jest/core/build/index.js
- /home/oss/cropperjs/node_modules/jest-cli/build/run.js
- /home/oss/cropperjs/node_modules/jest-cli/build/index.js
- /home/oss/cropperjs/node_modules/jest-cli/bin/jest.js
- /home/oss/cropperjs/node_modules/jest/bin/jest.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/oss/cropperjs/node_modules/braces/index.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)

fengyuanchen added a commit that referenced this pull request May 4, 2024
…t-ratio`, `initial-aspect-ratio`, `initial-coverage`, and `precise` properties reactive

fix #1124, #1163, #1164, #1165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant