Modal Open on Mouseleave

1 reply · opened Jan 10, 2017

LlawmotorsportsJan 10, 2017

Hello,

I want the cookie modal to open on mouseleave.

I have this which is close, but it's not working properly:


shown = false;
            $(document).mouseleave(function () {
                if (!shown) {
                    $('#myModal1').modal();
                    shown = true;
                }
            });

Do you have another way of achieving this?

SSemicolon WebSTAFFJan 12, 2017

Hello,

Consider using the following code:

var shown = false;
$(document).mouseleave( function(){
	if (!shown) {

		$.magnificPopup.open({
			items: { src: '#myModal1' },
			type: 'inline',
			mainClass: 'mfp-no-margins mfp-fade',
			closeBtnInside: true,
			fixedContentPos: true,
			removalDelay: 500
		}, 0);

		shown = true;
	}
});

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard