Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit f09d404

Browse files
author
Amir Khorsandi
committed
Set minimum size ration to 0.01
1 parent 7a6bf0a commit f09d404

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Lib/Snapshot/SnapshotTransformView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ private extension SnapshotContainerView {
134134
y: translateY)
135135
.scaledBy(x: scale, y: scale)
136136
var sizeRatioRow = options.pieceSizeRatio.height
137-
if sizeRatioRow == 0 {
138-
sizeRatioRow = 1
137+
if abs(sizeRatioRow) < 0.01 {
138+
sizeRatioRow = 0.01
139139
}
140140
var sizeRatioColumn = options.pieceSizeRatio.width
141-
if sizeRatioColumn == 0 {
142-
sizeRatioColumn = 1
141+
if abs(sizeRatioColumn) < 0.01 {
142+
sizeRatioColumn = 0.01
143143
}
144144
let rowCount = Int(1.0 / sizeRatioRow)
145145
let columnCount = Int(1.0 / sizeRatioColumn)

Samples/PagingLayoutSamples/Modules/LayoutDesigner/LayoutDesignerViewModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ class LayoutDesignerViewModel {
157157
let update: ((inout SnapshotTransformViewOptions) -> Void) -> Void = { [weak self] in
158158
self?.update(options: &options, closure: $0)
159159
}
160+
optionViewModels = [
161+
.init(title: "Piece size ratio", kind: .doubleSlider(current: options.pieceSizeRatio.pair) { n in
162+
update { $0.pieceSizeRatio = .by(pair: n) }
163+
})
164+
]
160165
}
161166
}
162167

0 commit comments

Comments
 (0)