Last active
December 14, 2015 10:08
-
-
Save bluespore/5069438 to your computer and use it in GitHub Desktop.
Closing interactive pop out/up areas such as modals and menus with jQuery.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
UX: Dealing with dynamic pop ups. | |
Clicking/touching the html will close anything | |
with a class of 'open' | |
Sean Bullock | |
*/ | |
$('html').on('click touchstart', function(){ | |
$('.open').removeClass('open'); | |
}); | |
/* | |
Be sure to include the elements here that you | |
want to interact with, e.g: modal with a form, | |
so as clicking inside it will not remove the open state. | |
Sean Bullock | |
*/ | |
$('.element1, .element2').on('click touchstart', function(e){ | |
e.stopPropagation(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment