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

If there's any clickable image behind the X, it loads the image instead of closing #365

Open
damian5000 opened this issue Jun 24, 2018 · 6 comments

Comments

@damian5000
Copy link

damian5000 commented Jun 24, 2018

Anytime there's a clickable image behind the X, it loads the image tapped behind the X instead of exiting Swipebox.

Mostly a big problem with galleries. Makes it very difficult for user to exit. Yes, they could swipe up, but the glaring X is invariably what they'll be trying.

Would love to see this solved.

@olibp
Copy link

olibp commented Aug 1, 2018

+1 it's reloading the whole page in my case because of a link behind the close button (on mobile only). Users can't always figure out the swipe up/down when no X is shown, so they ends up clicking reload or back instead.

@scrobbleme
Copy link

Workaround, change closeSlide to (add event.preventDefault):

closeSlide : function () {
    $( 'html' ).removeClass( 'swipebox-html' );
    $( 'html' ).removeClass( 'swipebox-touch' );
    $( window ).trigger( 'resize' );
    this.destroy();
    if(event){
        event.preventDefault();
    }
},

@thimolor
Copy link

Hi, I 'am getting this error in Chrome after I changed closeSlide:

"[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive."

How can I fix this? Thanks.

@intsfanatic
Copy link

Having the same issue. The code above works, but gives an error in the console after closing: "Unable to preventDefault inside passive event listener due to target being treated as passive."

@sparky-vision
Copy link

sparky-vision commented Jul 9, 2019

+1, I'm having the same issue with mobile browsers. I have a large gallery, and the X simply doesn't work if there's a clickable link behind it, leading to being unable to exit the gallery without reloading the page.

[edit] I thought maybe I could make an ugly hack to get around this by disabling SVGs, and replacing the transparent PNGs with JPGs, in case the click event wasn't being "seen" by the pixels, but this doesn't work, either. The code above doesn't work for me, either.

[edit 2] Actually, everything goes "through" the opened image, to the page below, including scrolling, which makes this extremely unusable on mobile Safari. (Probably other browsers, too, but I haven't tested those.

[edit 3] This code that I found works: #331 (comment)

@LittleTux75
Copy link

LittleTux75 commented May 8, 2020

if at https://github.com/brutaldesign/swipebox/blob/master/src/js/jquery.swipebox.js (Swipebox v1.4.4)

line 587

			$( '#swipebox-close' ).bind( action, function() {
				$this.closeSlide();
			} );

you change the code to

			$( '#swipebox-close' ).bind( action, function(event) {
				event.preventDefault();
				event.stopPropagation();
				$this.closeSlide();
			} );

this prevent to propagate the touch event to another underlying swipebox element on mobile device and consequently reopen the slideshow

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

7 participants