rodneyrehm / viewport-units-buggyfill

Making viewport units (vh|vw|vmin|vmax) work properly in Mobile Safari.
MIT License
1.59k stars 151 forks source link

Should be recalculated on resize? #70

Open chodorowicz opened 8 years ago

chodorowicz commented 8 years ago

The script recalculates on orientationchange event. I think we should recalculate dimensions on other events. One case I have currently problem with is scrolling on iOS Safari. When you scroll down the tab bar disappear and viewport height changes (expands by viewport height). We could use window.onresize event. Maybe there's some other way?

rodneyrehm commented 8 years ago

Are your problems resolved when initializing the buggyfill with { force: true }? we don't always listen to resize, but I don't remember why…

chodorowicz commented 8 years ago

I've checked it and force: true seems to work (although I don't understand why, I was thinking it would force px sizes on devices which support viewport units).

I've fixed this issue by adding (since disappearing tab bar on scroll triggers resize).

window.onresize = function() {
  viewportUnitsBuggyfill.refresh();
};

edit


OK, now I understand https://github.com/rodneyrehm/viewport-units-buggyfill/blob/master/viewport-units-buggyfill.js#L173

So this docs is not clear for me:

// ignore user agent force initialization viewportUnitsBuggyfill.init({force: true});

I doesn't say that with force: true you get onresize trigger too ;) (maybe naive) It seems resize should trigger refresh by default (since resize changes viewport height/width).

tracid commented 8 years ago

@rodneyrehm I think I know the/one reason: I used buggyfill to prevent the annoying behaviour of the smartphone-resizing of the viewheight when scrolling up/down. With {force:true} this behaviour occured again. So I prefer @chodorowicz 's solution... thanks for the hint!

aulneau commented 8 years ago

@tracid or @chodorowicz would you be able to provide an example as to the method you're using to fix the buggy behavior on mobile (address bar jumps).

Thanks so much (also I don't mean to hijack this thread).

lucho20pt commented 8 years ago

@aulneau The solution is non-related with buggyfill script