admin管理员组文章数量:1414613
Found a lot of modal window plugins, tried different configuration options for some like SimpleModal, LightBox... these are lightweight and have flexible configuration, but i'm missing one thing: i need to be able scroll modal window (when it exceed in height) with browser scrollbar like facebook gallery modal, or pinterest pin preview modal, any suggestions?
Found a lot of modal window plugins, tried different configuration options for some like SimpleModal, LightBox... these are lightweight and have flexible configuration, but i'm missing one thing: i need to be able scroll modal window (when it exceed in height) with browser scrollbar like facebook gallery modal, or pinterest. pin preview modal, any suggestions?
Share Improve this question asked Feb 6, 2012 at 8:50 Faustas MisiunasFaustas Misiunas 911 silver badge5 bronze badges2 Answers
Reset to default 4$(window).scroll(function(){
if($('#ux-dialog-test-container').dialog('isOpen') === true){
var dialogHeight = $('.ui-dialog').height();
var windowHeight = $(window).height();
var documentHeight = $(document).height();
var scrollLength = documentHeight - windowHeight;
var currentScrollTop = $(window).scrollTop();
var scrollPercentage = currentScrollTop/scrollLength;
var pixelsToSubtract = dialogHeight * scrollPercentage;
var newTop = 32 - pixelsToSubtract;
$('.ui-dialog').animate({top: newTop + 'px'}, 15, 'swing');
}
});
I know this an old question, but I was struggling with the same issue and found this a suitable solution. It basically gives the illusion of scrolling the modal dialog, when actually it is pushing the top higher as you scroll down. I calculated the percentage of window scrolled and used that percentage to adjust the "top:" css property. In my case I had the top set to 32px, as you can see I adjusted for in my calculations. Hope this helps someone somewhere!
OH! and this which I stole from another thread is needed in certain browsers to unlock the scroll (i.e. in chrome the click event for the scrollbar is suppressed if modal: true)
if ($.ui && $.ui.dialog) {
$.ui.dialog.overlay.events = $.map('focus,keydown,keypress'.split(','), function(event) { return event + '.dialog-overlay'; }).join(' ');
}
I know this works in IE8+ as well as Chrome and FF.
EDIT: Added check to see if dialog was open.
http://fstoke.me/jquery/window/
How can I open a Modal-Dialog window with scrollbars in javascript or jquery
本文标签: javascriptWhere to find jQuery quotscrollablequot modal window pluginStack Overflow
版权声明:本文标题:javascript - Where to find jQuery "scrollable" modal window plugin? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745173363a2646108.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论