Socket
Book a DemoInstallSign in
Socket

@deleteagency/page-locker

Package Overview
Dependencies
Maintainers
6
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deleteagency/page-locker

[Live Demo](https://delete-agency.github.io/page-locker/)

2.0.7
latest
Source
npmnpm
Version published
Maintainers
6
Created
Source

Page Locker

Live Demo

Motivation

On opening a modal window you have to prevent your main page from scrolling, so generally you can just set "overflow: hidden" on document.documentElement, but it won't work with iOS devices, so there is a need for a little bit tricky way via using "position: fixed" and setting the scroll position. So we can just use two simple methods to lock and unlock a page.

Installation

Use the package manager npm for installation.

$ npm install @deleteagency/page-locker

Usage

html {
    &.is-blocked {
        overflow: hidden;
    }

    &.is-blocked-touch {
        position: fixed;
        overflow-y: scroll;
        width: 100%;
        height: auto;
    }
}
import { PageLocker } from  '@deleteagency/page-locker';

const pageLocker = new PageLocker();

pageLocker.lock('modal');

API

pageLocker.lock(retainerId)

retainerId

Required
Type: string

pageLocker.unlock(retainerId)

retainerId

Required
Type: string

License

MIT

FAQs

Package last updated on 08 Jul 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.