Talor-A / react-native-message-bar

A notification bar alert displayed at the top of the screen for react-native
MIT License
55 stars 27 forks source link

Prevent bar from appearing when starting in landscape and rotating to portrait #10

Closed keith-kurak closed 7 years ago

keith-kurak commented 7 years ago

When starting the app with the device in landscape mode and then rotating to portrait, the MessageBar appears and takes up half the screen (I didn't even suspect this was the MessageBar until I opened the element inspector). This does not happen if you start in landscape, make a message appear, and then rotate- it only happens if no messages appear.

It appears that the appropriate offsets were not set to null based on the position until setNewState() was called, which (usually) happens on the first message. Therefore, all offsets changed by _changeOffsetByPosition() were initially set by zero. I'm not entirely sure why this does what it does, but it was the one difference I could identify between before-first-message and after-first-message, and it seems to fix this issue.

Talor-A commented 7 years ago

cool, I'll test this and should have it merged soon. thanks.

skicson commented 6 years ago

I still see this issue - I believe it is caused because the windowWidth and windowHeight are hardcoded at the top of the file. If those are changed to var instead of let, and the call to set those are moved to render it seems to work properly.