Skip to content

clampDuration property for FlyToOptions #6782

@niko-gardenanet

Description

@niko-gardenanet

User Story

As a developer using maplibre-gl-js, I want camera animations to smoothly cap their duration instead of becoming instant when exceeding a limit, so that transitions remain predictable and pleasant.

Rationale

FlyToOptions currently supports duration and maxDuration.
When the internally calculated duration exceeds maxDuration, the animation is forced to 0 ms. This behavior results in abrupt jumps instead of a shortened animation.

A more intuitive option would be to clamp the duration to a maximum value.
To maintain backwards compatibility, a new optional field could be added:

clampDuration?: number

If provided, the animation duration becomes:

duration = min(calculatedDuration, clampDuration)

This avoids the “jump to instant” effect while preserving existing maxDuration semantics.

Impact

Without this option, developers cannot easily ensure smooth transitions when animations exceed a desired maximum duration. A clampDuration field would improve UX for applications relying on consistent camera movement, without breaking existing code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need more infoFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions