Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sect/100vh

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sect/100vh

Lightweight JS package for easy overcoming the problem with 100vh on mobile devices

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@sect/100vh

MIT license

Lightweight JS package for easy overcoming the problem with 100vh on mobile devices :iphone:

How does it work?

It creates the CSS variable called --vh at the <html> tag and vh variable in the window, which is changed on orientation change & resize event and stays still during scroll. This will prevent the page "jumping" on scroll, which leads to bad user experience.

Important note:

This will stay still only on mobile devices, on desktop the value changes together with the viewport. That means that it can be used on any resolution and there is no need for additional css media queries.

Installation

Install package in your project

npm i @sect/100vh

Initialization

Import the package and run the init function at the page start.
(for Nuxt.js/Vue app it can be initialized in plugins, if you're using other technology – init the script above all the other code)

import vh from '@sect/100vh';

vh.init();

Browser:

<!-- Include 100vh from dist -->
<script src="dist/100vh.umd.js"></script>
<!-- Initialize (you can do this whenever you want) -->
<script>
vh.init();
</script>

Examples

CSS

.section {
  height: var(--vh);
}

JS

window.querySelectorAll('section').style.height = window.vh;

Contributing

Want to help improve this plugin? Great!
Project is open-source so fork repo and join us!

License

MIT License © Sparing Interactive

Keywords

FAQs

Package last updated on 09 May 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc