Flyer53 / jsPanel3

A jQuery Plugin to create highly configurable floating panels, modals, tooltips, hints/notifiers or contextmenus for use in a backend solution and other web applications.
http://v3.jspanel.de/
Other
89 stars 21 forks source link

Unable to resize height to 'auto' for a modal panel. #13

Closed burtnoir closed 8 years ago

burtnoir commented 8 years ago

I am using the resize method to deal with changing content. It works well on normal panels using specific values and the 'auto' value.

On a modal panel I find that I cannot set the height to 'auto'. There's no error, it just doesn't appear to do anything. I can set the width to 'auto'. I even tried resizing the modal dialog example after inserting some extra content and it shows the same behaviour.

Am I missing something?

Thanks

Flyer53 commented 8 years ago

The issue behind this seems to be that you never really know how a browser calculates the dimensions when setting width/height to auto. To solve this you should set widht and/or height of the content section to auto after inserting new content and before resizing the complete panel. The following example seems to work fine but I quickly tested this only on FF:

var test = $.jsPanel({
    paneltype: 'modal',
    contentSize: '400 50'
});

window.setTimeout(function() {
    test.content.append("<ol><li>Item</li><li>Item</li><li>Item</li><li>Item</li><li>Item</li></ol>");
    test.content.css({width:'auto', height:'auto', padding: '10px'});
    test.resize(null, 'auto').reposition();
}, 1000);
burtnoir commented 8 years ago

Thanks for your help, I'll give that a try.

burtnoir commented 8 years ago

I can confirm that this approach works so I just need to make sure I always do this after I change the content of a modal panel.