watusi / jquery-mobile-iscrollview

JQuery Mobile widget plug-in for easy use of the iScroll javascript scroller.
408 stars 183 forks source link

Scrollbar hidden on page load #113

Open pierluigi opened 11 years ago

pierluigi commented 11 years ago

If there are images without the height attribute declared, the scrollbar will not be shown due to an incorrect height calculation.

Here's a demo : http://www.negativelabs.com/dev/tests/jqm-iscroll/

(resize your window and the scrollbar will reappear instantly).

I guess this is due to the images not having been loaded yet when the iScroll is initialized. Just for testing I've added a timeout of 100ms before the element.iscrollview() initialization line and that seems to "fix" the issue.

What would be the best way to fix this without setting image height explicitly (in our project the images must have fluid dimensions that scale together with the window).

Thanks

UPDATE A more appropriate way to alleviate the issue is by replacing

elements.iscrollview();

with

elements.each(function(i, e) {
    $('img', e).load(function() {
        $(e).iscrollview();
    });
});

(at the bottom of jquery.mobile.iscrollview.js )

But it's a workaround really... any other ideas?