Improvements with image viewer.

This commit is contained in:
Marcin Czachursk 2023-02-20 11:55:38 +01:00
parent dbaf299f15
commit e5f387a04e
2 changed files with 6 additions and 6 deletions

View File

@ -979,7 +979,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 14;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;
@ -1016,7 +1016,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 14;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;

View File

@ -59,7 +59,7 @@ struct ImagesViewer: View {
var magnificationGesture: some Gesture {
MagnificationGesture()
.onChanged { amount in
currentMagnification = amount - 1
currentMagnification = (amount - 1) * self.finalMagnification
}
.onEnded { amount in
let finalMagnification = finalMagnification + currentMagnification
@ -103,9 +103,9 @@ struct ImagesViewer: View {
// Changing angle.
self.rotationAngle = Angle(degrees: Double(self.currentOffset.width / 30))
} else {
// Bigger images we can move only horizontally.
self.currentOffset = CGSize(width: amount.translation.width + self.accumulatedOffset.width, height: 0)
print(currentOffset.width)
// Bigger images we can move only horizontally (we have to include magnifications).
let offsetWidth = (amount.translation.width / self.finalMagnification) + self.accumulatedOffset.width
self.currentOffset = CGSize(width: offsetWidth, height: 0)
}
} .onEnded { amount in
self.accumulatedOffset = CGSize(width: amount.translation.width + self.accumulatedOffset.width,