viewerjs
viewerjs copied to clipboard
feat: add new 'edgeLimit' option
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
- [x] 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
- [x] No
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
- [x] 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.)
- [x] Chrome
- [x] Firefox
- [x] Safari
- [x] Edge
- [ ] IE
If adding a new feature, the PR's description includes:
- [x] A convincing reason for adding this feature
- [ ] Related documents have been updated
- [x] 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 Report
Merging #429 (341a3ad) into master (0cecec2) will decrease coverage by
0.69%
. The diff coverage is31.57%
.
@@ 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%) |
:arrow_down: |
src/js/methods.js | 88.55% <100.00%> (+0.02%) |
:arrow_up: |
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.
Good job, but still have some problems:
- Cannot move to the edge when zooming out 200% or larger.
- Test cases for the new options.
- Usage documentation for the new options.
- Don't push the bundled files.
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
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
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?
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.
In the given example, it will move the image into view if it is invisible after zoomed out now.