Skip to content

Commit

Permalink
Fix initial zoom ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
mgroeneweg committed Nov 21, 2022
1 parent ac79cc2 commit 7a57782
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nativeimageviewer",
"widgetName": "NativeImageViewer",
"version": "3.1.0",
"version": "3.1.1",
"description": "Mendix native image viewer",
"copyright": "ITvisors 2020",
"author": "Marcel Groeneweg",
Expand Down
12 changes: 4 additions & 8 deletions src/NativeImageViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ export function NativeImageViewer({
const pixelDensity = PixelRatio.get();
imageWidth = PixelRatio.roundToNearestPixel(imageWidth / pixelDensity);
imageHeight = PixelRatio.roundToNearestPixel(imageHeight / pixelDensity);
let zoomRatio = 0;
if (window.height > window.width) {
// Portrait
zoomRatio = window.width / imageWidth;
} else {
// Landscape
zoomRatio = window.height / imageHeight;
}
// Calculate the smallest zoom ratio and use that for the image zoom ratio.
const zoomRatioWidth = window.width / imageWidth;
const zoomRatioHeight = window.height / imageHeight;
const zoomRatio = zoomRatioHeight < zoomRatioWidth ? zoomRatioHeight : zoomRatioWidth;

const renderImage = () => {
switch (imageSource) {
Expand Down
2 changes: 1 addition & 1 deletion src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="NativeImageViewer" version="3.1.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="NativeImageViewer" version="3.1.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="NativeImageViewer.xml"/>
</widgetFiles>
Expand Down
Binary file modified test/TestNativeImageViewer.mpr
Binary file not shown.
Binary file modified test/widgets/itvisors.NativeImageViewer.mpk
Binary file not shown.

0 comments on commit 7a57782

Please sign in to comment.