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

Prevent caption selection from scrolling screen #1192

Open
tomdav999 opened this issue Aug 22, 2016 · 2 comments
Open

Prevent caption selection from scrolling screen #1192

tomdav999 opened this issue Aug 22, 2016 · 2 comments
Labels

Comments

@tomdav999
Copy link

tomdav999 commented Aug 22, 2016

If you try to select the caption with the mouse, touchscreen, etc. it scrolls the screen. To prevent this I made the following change in photoswipe.js:

code revised below

@tomdav999
Copy link
Author

tomdav999 commented Aug 29, 2016

Actually, to allow text selection via drag in chrome you need to make the changes at the top of the function before preventDefault();

    // Pointermove/touchmove/mousemove handler
    _onDragMove = function(e) {

    // add these 7 lines below before e.preventDefault();
    var el = document.elementFromPoint(_currPoint.x, _currPoint.y);
    while (el && !el.className) {
        el = el.parentElement;
    }
    if (el.className.indexOf('__caption') > -1) {
                return;
        }
    // add these 7 lines above before e.preventDefault();
    e.preventDefault();

@tomdav999
Copy link
Author

tomdav999 commented Sep 1, 2016

One more tweak is needed (to prevent pswp from zooming when drag is released outside of caption). Setting _moved = true; seems to do the trick. Edit: whoops, setting _moved = true; prevented drag inside caption in desktop Chrome. Setting _mainScrollAnimating = true; seems to work better.

if (el.className.indexOf('__caption') > -1) {
    _mainScrollAnimating = true; // prevent photoswipe default tap event when drag released outside caption
    return; // to allow drag select inside caption don't call e.preventDefault();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants