Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CenteredZoomState - Prevent timeline.offset on right side? #37

Open
justinlevi opened this issue Nov 16, 2017 · 0 comments
Open

CenteredZoomState - Prevent timeline.offset on right side? #37

justinlevi opened this issue Nov 16, 2017 · 0 comments

Comments

@justinlevi
Copy link

I have created a CustomCenteredZoomState class which extends ui.states.CenteredZoomState. I see the example to prevent the timeline.offset from going negative, but I'm struggling with how to limit the user from scrolling the waveform infinitely in the positive direction.

I see Example 2, but I'm not sure the best way to get the view.width in this class? I would like to limit dragging to the maximum of the audio track if that makes sense. I'll keep working at it, just wondering if this is something that has already been solved...

    // Example 1: Prevent timeline.offset to be negative
    timeContext.offset = Math.min(timeContext.offset, 0);
    //
    // Example 2: Keep in container when zoomed out
    // if (timeContext.stretchRatio < 1) {
    //   const minOffset = timeContext.timeToPixel.invert(0);
    //   const maxOffset = timeContext.timeToPixel.invert(view.width - timeContext.timeToPixel(timeContext.duration));
    //   timeContext.offset = Math.max(timeContext.offset, minOffset);
    //   timeContext.offset = Math.min(timeContext.offset, maxOffset);
    // }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant