All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.nacular.doodle.controls.carousel.DampedTransitioner.kt Maven / Gradle / Ivy

There is a newer version: 0.10.4
Show newest version
package io.nacular.doodle.controls.carousel

import io.nacular.doodle.controls.carousel.Carousel.ItemMarkers
import io.nacular.doodle.controls.carousel.CarouselBehavior.Transitioner
import io.nacular.doodle.geometry.Vector2D
import io.nacular.doodle.geometry.times
import io.nacular.doodle.scheduler.AnimationScheduler
import io.nacular.doodle.scheduler.Task
import io.nacular.doodle.time.Timer
import io.nacular.doodle.utils.Completable
import io.nacular.doodle.utils.CompletableImpl
import io.nacular.doodle.utils.Pausable
import io.nacular.doodle.utils.autoCanceling
import io.nacular.doodle.utils.observable
import io.nacular.doodle.utils.zeroMillis
import io.nacular.measured.units.InverseUnits
import io.nacular.measured.units.Measure
import io.nacular.measured.units.Square
import io.nacular.measured.units.Time
import io.nacular.measured.units.Time.Companion.milliseconds
import io.nacular.measured.units.Time.Companion.seconds
import io.nacular.measured.units.div
import io.nacular.measured.units.times
import kotlin.math.E
import kotlin.math.abs
import kotlin.math.pow


/**
 * Carousel [Transitioner] that provides smooth, physics-based deceleration at the end of a Carousel's
 * manual movement.
 *
 * @param timer used to track current time
 * @param scheduler used to manage animation
 * @param decelerationTime indicating how quickly stops should decelerate to 0 velocity
 * @param dampLevel indicating how much critical damping should be applied during stopping
 *
 * @see Carousel.completeManualMove
 */
public open class DampedTransitioner(
    private val timer           : Timer,
    private val scheduler       : AnimationScheduler,
    private val decelerationTime: Measure




© 2015 - 2025 Weber Informatics LLC | Privacy Policy