jquery - How to hide Facebook chat boxes on Window resize? -


i'm trying reproduce in jquery, how facebook hide or show opened chat boxes when viewport size changes. basically, if have 6 chat windows open, , if resize or shrink browser, of chat windows hidden if visually 6 can't fix screen size.

i'm using function $(window).resize() detect if total width of open windows plus margin greater window's width, hide first chat window, or show last 1 if there's space more windows. basic pop or push stack...

my method isn't working because whenever resize runs, script trying hide or show windows... (see code below)

any suggestions appreciated.

chatwidget.isenoughroom = function() {

return ($(window).width() > ((chatwidget.window_width * $('.chatwindowwidget:visible').length) + chatwidget.contactlist_width + 100));

};

$(window).resize(function(){

    if(!chatwidget.isenoughroom()) {             $('.chatwindow:visible:last').hide() ;     } else {         $('.chatwindow:hidden:last').show() ;     } 

})

your problem seams related multiple triggering of resize function every time resize window. tested in chrome , triggered twice. give try: https://github.com/louisremi/jquery-smartresize


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -