Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

Don't preventDefault() for swipe movements orthogonal to scroller direction #27

Open
waldbaerkoch opened this issue Feb 22, 2013 · 1 comment

Comments

@waldbaerkoch
Copy link

Consider a horizontal scroller (scrollingY: false) in a vertically scolllable page. Currently vertical swipe movements on the scroller will not trigger the native page scroll, because of
javascript rawEvent.preventDefault(); in _updateScroll.

For scrollers with scrollingY: false you could try to restrict rawEvent.preventDefault(); to only mainly horizontal swipe movements and correspondingly to mainly vertical swipes for scrollers with scrollingX: false.

@waldbaerkoch
Copy link
Author

I think it's this:

                // Determine whether to prevent the default scroll event - if the scroll could still
                // be triggered, prevent the default to avoid problems (particularly on PlayBook)
                if (_instanceOptions.bouncing || scrollInterrupt || (_scrollableAxes.x && gesture.x && distancesBeyondBounds.x < 0) || (_scrollableAxes.y && gesture.y && distancesBeyondBounds.y < 0)) {
                    rawEvent.preventDefault();
                }

If you remove it and after

            // Update axes if appropriate
            for (axis in _scrollableAxes) {
                if (_scrollableAxes.hasOwnProperty(axis)) {
                    if (targetPositions[axis] > 0) {
                        targetPositions[axis] = _modifyDistanceBeyondBounds(targetPositions[axis], axis);
                    } else if (targetPositions[axis] < _metrics.scrollEnd[axis]) {
                        targetPositions[axis] = _metrics.scrollEnd[axis] + _modifyDistanceBeyondBounds(targetPositions[axis] - _metrics.scrollEnd[axis], axis);
                    }

                    if (_reqAnimationFrame) {
                        _animationTargetPosition[axis] = targetPositions[axis];
                    } else {
                        _setAxisPosition(axis, targetPositions[axis]);

add

if (Math.abs(targetPositions[axis]) > 10) {
    rawEvent.preventDefault();
}

it may work.

naltatis added a commit to naltatis/ftscroller that referenced this issue Feb 5, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant