Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-ios-keyboard-viewport
Advanced tools
A React hook that dynamically adjusts element positioning during iOS keyboard display, utilizing the Visual Viewport API for precise calculations.
A React hook that dynamically adjusts element positioning during iOS keyboard display, utilizing the Visual Viewport API for precise calculations.
Install from npm:
npm install react-ios-keyboard-viewport
This hook generates a style object for elements that you want to fix to the Top/Center/Bottom of the screen. The style object is only generated when the keyboard is displayed on iOS, so please use this style object to override after styling for the normal display state.
import { useFixedStyleWithIOsKeyboard } from 'react-ios-keyboard-viewport';
const Component = () => {
const { fixedTop, fixedCenter, fixedBottom } = useFixedStyleWithIOsKeyboard();
return (
<div className="wrapper">
<header className="header" style={fixedTop}>
Fixed to Top
</header>
<div className="center" style={fixedCenter}>
Fixed to Center
</div>
<footer className="footer" style={fixedBottom}>
Fixed to Bottom
</footer>
</div>
);
};
This hook calculates the distance from the top of the page to the Top/Center/Bottom of the visualViewport. The calculated values are used in the styles of useFixedStyleWithIosKeyboard, but they can also be used to freely customize styles in cases where that hook is not suitable.
import { useViewportDistanceFromPageTop } from 'react-ios-keyboard-viewport';
const { toTop, toCenter, toBottom } = useViewportDistanceFromPageTop();
This hook calculates the height of the virtual keyboard of iOS. It is used inside useFixedStyleWithIosKeyboard to determine whether the iOS keyboard is open.
import { useiOsKeyboardHeight } from 'react-ios-keyboard-viewport';
const iOsKeyboardHeight = useiOsKeyboardHeight();
Feel free to open an issue or make a pull request.
Distributed under the MIT License. See LICENSE for more information.
FAQs
A React hook that dynamically adjusts element positioning during iOS keyboard display, utilizing the Visual Viewport API for precise calculations.
The npm package react-ios-keyboard-viewport receives a total of 28 weekly downloads. As such, react-ios-keyboard-viewport popularity was classified as not popular.
We found that react-ios-keyboard-viewport demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.