Module Dimensions-BsReactNative
type dimensions
= Js.t({. width: int, height: int, scale: float, fontScale: float, })
;You can read more on
Dimensions
API usage in official docs: https://facebook.github.io/react-native/docs/dimensionsExample of use
get(`window)
let windowDimensions = Dimensions.get(`window); Js.log(windowDimensions##width); Js.log(windowDimensions##height); Js.log(windowDimensions##scale); Js.log(windowDimensions##fontScale);
get(`screen)
let screenDimensions = Dimensions.get(`screen); Js.log(screenDimensions##width); Js.log(screenDimensions##height); Js.log(screenDimensions##scale); Js.log(screenDimensions##fontScale);
addEventListener and removeEventListener
let handler = dimensions => Js.log(dimensions##screen##width); Dimensions.addEventListener("change", handler); Dimensions.removeEventListener("change", handler);
Function parameters
get
[< | `screen | `window] => dimensions
reference:
type dimensions = { . "width": int, "height": int, "scale": float, "fontScale": float, };
addEventListener
( string, { . "screen": dimensions, "window": dimensions, } => unit ) => unit
reference:
type dimensions = { . "width": int, "height": int, "scale": float, "fontScale": float, };
removeEventListener
( string, { . "screen": dimensions, "window": dimensions, } => unit ) => unit
reference:
type dimensions = { . "width": int, "height": int, "scale": float, "fontScale": float, };
let get: [< `screen | `window ] => dimensions;
let addEventListener: string => (Js.t({. screen: dimensions, window: dimensions, }) => unit) => unit;
let removeEventListener: string => (Js.t({. screen: dimensions, window: dimensions, }) => unit) => unit;