scoop:scoop.ui.component:0.1.0
src/carousel/wheel.scoop
Selected production source · src/carousel/wheel.scoop
1
package scoop.ui.component3
/** Attachment groups feed native horizontal wheel movement into the existing carousel position. */4
internal fun carouselWheel(control: CarouselControl, amount: Double): Double {5
if (!control.available() || panelPresent(control.gesture) || amount == 0.0)6
return 0.07
val shape = control.geometry!!8
val before = control.position9
val next = upperBound(shape.track.maximum, lowerBound(0.0, before + amount))10
control.motion.snapTo(next)11
return next - before12
}14
internal fun carouselFinishWheel(control: CarouselControl) {15
if (!control.available() || panelPresent(control.gesture))16
return17
val target = carouselNearest(control.geometry!!.track, control.position, 0.0, 0.0) ?: return18
control.select(target.index, true, Some(target.position))19
}