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

List out of window #80

Open
RedskyThirty opened this issue Oct 3, 2018 · 2 comments
Open

List out of window #80

RedskyThirty opened this issue Oct 3, 2018 · 2 comments

Comments

@RedskyThirty
Copy link

RedskyThirty commented Oct 3, 2018

May be this will help some guys.
TODO: Manage "$(window).resize()"

`
// Open/close
$(document).on('click.nice_select', '.nice-select', function(event) {
var $dropdown = $(this);
var $list = $dropdown.find('.list'); // NEW LINE

		$('.nice-select').not($dropdown).removeClass('open');
		$dropdown.toggleClass('open');

		if ($dropdown.hasClass('open')) {
			$dropdown.find('.option');
			$dropdown.find('.focus').removeClass('focus');
			$dropdown.find('.selected').addClass('focus');

			// NEW LINES

			if($list.attr('style')) $list.removeAttr('style'); // Reset

			var maxHeight = ($(window).innerHeight() - $list.offset().top - 60); // "60" => spacing

			if($list.height() > maxHeight)
			{
				$list.css({
					'height': maxHeight,
					'overflow-y': 'auto',
					'-webkit-overflow-scrolling': 'touch'
				});
			}
		} else {
			$dropdown.focus();

			if($list.attr('style')) $list.removeAttr('style'); // NEW LINE
		}
	});

`

@miagile
Copy link

miagile commented Oct 7, 2018

Would you mind to send a PR ?

@RedskyThirty
Copy link
Author

RedskyThirty commented Oct 8, 2018 via email

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

2 participants