Skip to content

Commit f5c3b01

Browse files
committed
Feat: add comments for the changes as requested
1 parent 12e7c70 commit f5c3b01

File tree

1 file changed

+11
-0
lines changed
  • packages/react-native-web/src/exports/Dimensions

1 file changed

+11
-0
lines changed

packages/react-native-web/src/exports/Dimensions/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ export default class Dimensions {
8080
let height;
8181
let width;
8282

83+
/*
84+
* iOS does not update viewport dimensions on keyboard open/close
85+
* So, we are using window.visualViewport(https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport)
86+
* instead of document.documentElement.clientHeight
87+
* But we are still using document.documentElement.clientWidth as fallback
88+
* because it was requested by the original repo owner
89+
*/
8390
if (win.visualViewport) {
8491
const visualViewport = win.visualViewport;
8592
height = Math.round(visualViewport.height);
@@ -136,6 +143,10 @@ export default class Dimensions {
136143
}
137144

138145
if (canUseDOM) {
146+
/*
147+
* Same here as in _update method
148+
* keeping the previous implementation as fallback
149+
*/
139150
if (window.visualViewport) {
140151
window.visualViewport.addEventListener('resize', Dimensions._update, false);
141152
} else {

0 commit comments

Comments
 (0)