Skip to content

When duration is passed, the Scene starts 1px late #299

@kasparsj

Description

@kasparsj

When you pass a duration to a Scene, the Scene actually starts 1px after the triggerElement.
This is not the case when duration is not passed in.
I had a look a the code, and I think this is because how newProgress is calculated and later evaluated.

if (_options.duration > 0) {
    newProgress = (scrollPos - _scrollOffset.start) / (_scrollOffset.end - _scrollOffset.start);
} else {
    newProgress = scrollPos >= _scrollOffset.start ? 1 : 0;
}

Here you can see that:

  1. when duration > 0 and scrollPos equals _scrollOffset.start, newProgress will be 0.
  2. when duration <= 0 and scrollPos equals _scrollOffset.start, newProgress will be 1.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions