dimsemenov / PhotoSwipe

JavaScript image gallery for mobile and desktop, modular, framework independent
http://photoswipe.com
MIT License
24.18k stars 3.31k forks source link

long tap trigger tapToClose, How to avoid? #1644

Open lfyfly opened 5 years ago

lfyfly commented 5 years ago
"photoswipe": "^4.1.3",
luoyang125024608 commented 5 years ago

if you want to use pswp on mobile , see the photoswipe.js in https://github.com/luoyang125024608/vue-photoswipe-mobile repo

icaife commented 4 years ago

find photoswipe/dist/photoswipe-ui-default.js and copy it, overwrite bindEvents

        // bind events for UI
        _listen('bindEvents', function() {
            let st;
            let canTap = true;
            framework.bind(_controls, 'pswpTap click', _onControlsTap);
            framework.bind(pswp.scrollWrap, 'touchstart', () => {
                st = +new Date();
            });
            framework.bind(pswp.scrollWrap, 'touchend', () => {
                canTap = +new Date() - st < 200;
            });
            framework.bind(pswp.scrollWrap, 'touchcancel', () => {
                canTap = +new Date() - st < 200;
            });
            framework.bind(pswp.scrollWrap, 'pswpTap', (...args) => {
                canTap && ui.onGlobalTap(...args);
            });

            if (!pswp.likelyTouchDevice) {
                framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
            }
        });