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

Optionally limit horizontal, vertical autoScroll #255

Merged
merged 1 commit into from
Sep 13, 2015
Merged

Optionally limit horizontal, vertical autoScroll #255

merged 1 commit into from
Sep 13, 2015

Conversation

73rhodes
Copy link

Suggestion to add the ability to optionally confine autoScroll in the horizontal or vertical direction.

@taye
Copy link
Owner

taye commented Aug 15, 2015

I would think it better to change the speed option to velocityX and velocityY so that a 0 value would disable autoScroll in that axis. The autoScroll method could be kept backwards compatible simply by using the given speed (if any) as the values for velocityX/Y.

@73rhodes
Copy link
Author

73rhodes commented Aug 15, 2015 via email

@73rhodes
Copy link
Author

How would you deal with autoScroll.speed = options.speed ?

@taye
Copy link
Owner

taye commented Aug 25, 2015

I'm not sure what you mean. When/how would that happen?

@73rhodes
Copy link
Author

That line is within the autoScrollMove function. The speed property is passed on this way, and velocityX / velocityY don't translate easily into a single speed property. This is why simple flags to disable horizontal or vertical scrolling appeared to be the simplest progressive enhancement...

@taye
Copy link
Owner

taye commented Sep 2, 2015

That line is actually obsolete. Around line 189 is where changes need to be made to something like this:

var dtx = (now - autoScroll.prevTimeX) / 1000,
    dty = (now - autoScroll.prevTimeY) / 1000,
    vx, vy, sx, sy;

// velocity: { x: pxPerS, y: pxPerS }
if (options.velocity) {
    vx = options.velcoity.x;
    vy = options.velcoity.y;
}
else {
    vx = vy = options.speed;
}

sx = vx * dt;
sy = vy * dt;
...

Perfect backwards compatibility can be maintained. I think that having different X and Y velocities for scroll could be useful but I'm not sure. The only use case that I can think of is extending the current autoScroll so that the scroll velocity depends on the distance to the container edge.

@73rhodes
Copy link
Author

Thanks for the suggestion. Implemented and tested; works great!

taye added a commit that referenced this pull request Sep 13, 2015
Optionally limit horizontal, vertical autoScroll
@taye taye merged commit b006d99 into taye:master Sep 13, 2015
@pumpknhd
Copy link

@taye Does the Velocity option still work? I seem to be unable to restrict the auto-scroll to just the Y axis. Thank you.

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

Successfully merging this pull request may close these issues.

3 participants