Skip to content

Commit 97924b0

Browse files
committed
fix minuteIncrement interpolation on buttons, close #167
1 parent 5ffaca5 commit 97924b0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib/components/Time.svelte

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,17 @@
225225
val += 12;
226226
}
227227
if (isMinuteView && minuteIncrement !== 1) {
228-
val = val > selectedMinutes ? selectedMinutes + minuteIncrement : selectedMinutes - minuteIncrement;
228+
if (e.isKeyboard) {
229+
val = val > selectedMinutes ? selectedMinutes + minuteIncrement : selectedMinutes - minuteIncrement;
230+
} else if (val % minuteIncrement !== 0) {
231+
// interpolate click to nearest 'possible' value
232+
const diff = val % minuteIncrement;
233+
const prev = val - diff;
234+
const next = prev + minuteIncrement;
235+
val = next - val < val - prev
236+
? next
237+
: prev;
238+
}
229239
}
230240
231241
innerDate[setter](val);
@@ -235,6 +245,7 @@
235245
const clientX = e.clientX - rect.left;
236246
const clientY = e.clientY - rect.top;
237247
const cntX = 130, cntY = 130;
248+
const cntX = 110, cntY = 110;
238249
let quadrant = null;
239250
if (clientX > cntX) {
240251
quadrant = clientY > cntY ? 2 : 1

0 commit comments

Comments
 (0)