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: add new 'edgeLimit' option #429

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kangw3n
Copy link

@kangw3n kangw3n commented Dec 1, 2020

fixed #352

added edgeLimit option to limit move event out of screen/container. default edgeRatio is 0.5 which based on moveable image.

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 default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • 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:

@codecov-io
Copy link

codecov-io commented Dec 1, 2020

Codecov Report

Merging #429 (341a3ad) into master (0cecec2) will decrease coverage by 0.69%.
The diff coverage is 31.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #429      +/-   ##
==========================================
- Coverage   75.29%   74.60%   -0.70%     
==========================================
  Files           8        8              
  Lines        1368     1382      +14     
==========================================
+ Hits         1030     1031       +1     
- Misses        338      351      +13     
Impacted Files Coverage Δ
src/js/utilities.js 46.81% <0.00%> (-2.95%) ⬇️
src/js/methods.js 88.55% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0cecec2...341a3ad. Read the comment docs.

@fengyuanchen
Copy link
Owner

fengyuanchen commented Dec 5, 2020

Good job, but still have some problems:

  1. Cannot move to the edge when zooming out 200% or larger.
  2. Test cases for the new options.
  3. Usage documentation for the new options.
  4. Don't push the bundled files.

@fengyuanchen
Copy link
Owner

As of v.1.9.0, you can use the move event to limit the moving range, here is an example:

https://fengyuanchen.github.io/viewerjs/examples/moving-range-limit.html

@kangw3n
Copy link
Author

kangw3n commented Dec 7, 2020

Brilliant Idea, Thanks a lot, maxOffsetPercentage do solve the first question as well, I'm just starting to rewrite and thinking the possibility to implement this feature on handler method like move and by then you've just done it.

BTW, should moving range limitation to be the default behavior of the plugin? I can't think of a use case that will allow to move image off of screen? So the question is, do we need to implement as an options or in other way is to made it as default behavior? I'm willing to help for moving it to the options method if you don't mind.

Anyway, You may close this PR anytime you like, thanks

@kangw3n
Copy link
Author

kangw3n commented Dec 7, 2020

As of v.1.9.0, you can use the move event to limit the moving range, here is an example:

https://fengyuanchen.github.io/viewerjs/examples/moving-range-limit.html

Minor bug detected, while zoomin around 300% and stick to edge of the screen, triggering toggle event (dbclick) may cause image out off canvas due to 100% centering issues,

This issue might be solved if we could dispatch move event along with zoomTo event or other similar event that will cause marginTop to moving the picture, perhaps?

@fengyuanchen
Copy link
Owner

Yes, the moving range limitation should be the default behavior but can be off if the user wants, so a new option defaults to true will be good.

@fengyuanchen
Copy link
Owner

In the given example, it will move the image into view if it is invisible after zoomed out now.

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.

图片容易被移除屏幕外,建议优化一些移动端的使用体验。
3 participants