Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Functions

tween

  • tween(olMap: undefined | Map, durationInMillis: number, start?: number, end?: number, startAt?: number): Observable<number>
  • Creates an Observable which emits a number range from "start" (default 0) to "end" (default 1) linearly interpolated over the given amount of time. Each emit is synchronized to the given map's postcompose phase, essentially making them animation frames with information about the fraction of the duration elapsed. The sequence is guaranteed to start with "start" as the first emitted value, and end with "end", neither over- nor under-shooting, and the Observable completes after that. (This makes it easy to, say, remove the animated feature in a "finally" or completion handler).

    Parameters

    • olMap: undefined | Map

      The map to synchronize with. If the map is undefined, the Observable will emit a single "end" value and complete, jumping directly to the final state without any animation.

    • durationInMillis: number

      The duration of the animation

    • start: number = 0

      The start value. The observable will emit this value immediately.

    • end: number = 1

      The end value. The observable will clamp the last emitted value to this.

    • Optional startAt: number

      If given, the observable will start emitting from this value, proportionally shortening the duration. E.g. if a tween runs from 0 to 1 in 1000ms, and is given a startAt value of 0.25, it will run from 0.25 to 1 in 750ms. (The purpose of this is to pick up where a previous animation left off if canceled midway, segueing fluidly between animations).

    Returns Observable<number>