safe-area-insets
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

safeAreaInsets

Use javascript to get the safe area insets.

Chinese documentation : 中文文档

Precondition

  • WKWebview
  • viewport-fit=cover

Install

NPM

npm install safe-area-insets --save

UMD

https://unpkg.com/safe-area-insets/out/umd/index.min.js

Use

Require

const safeAreaInsets = require('safe-area-insets')

Safe Area Info

console.log('safeAreaInsets.support', safeAreaInsets.support)
console.log('safe-area-inset-top', safeAreaInsets.top)
console.log('safe-area-inset-left', safeAreaInsets.left)
console.log('safe-area-inset-right', safeAreaInsets.right)
console.log('safe-area-inset-bottom', safeAreaInsets.bottom)

Listening Change Event

function callback(style){
    console.log(style)
}
// add
safeAreaInsets.onChange(callback)
// remove
safeAreaInsets.offChange(callback)

Related Reading

Designing Websites for iPhone X

Package Sidebar

Install

npm i safe-area-insets

Weekly Downloads

13,803

Version

1.4.1

License

ISC

Unpacked Size

23.3 kB

Total Files

12

Last publish

Collaborators

  • guoshengqiang