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

@zag-js/remove-scroll

Package Overview
Dependencies
Maintainers
1
Versions
721
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/remove-scroll - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

8

dist/index.d.ts

@@ -1,7 +0,1 @@

interface BodyScrollOptions {
disabled?: boolean;
document?: Document;
}
export declare function preventBodyScroll(options?: BodyScrollOptions): () => void;
export {};
//# sourceMappingURL=index.d.ts.map
export declare function preventBodyScroll(_document?: Document): () => void;

23

dist/index.js

@@ -0,1 +1,2 @@

"use strict";
var __defProp = Object.defineProperty;

@@ -26,3 +27,3 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

// ../core/dist/index.mjs
// ../dom/dist/index.mjs
var isDom = () => typeof window !== "undefined";

@@ -35,3 +36,3 @@ function getPlatform() {

var pt = (v) => isDom() && v.test(getPlatform());
var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
var isMac = () => pt(/^Mac/) && !isTouchDevice;

@@ -42,3 +43,3 @@ var isApple = () => pt(/mac|iphone|ipad|ipod/i);

// src/index.ts
var identifier = "data-scroll-lock";
var LOCK_CLASSNAME = "data-scroll-lock";
function assignStyle(el, style) {

@@ -73,14 +74,11 @@ if (!el)

}
function preventBodyScroll(options = {}) {
function preventBodyScroll(_document) {
var _a;
const { document: docProp, disabled } = options;
if (disabled)
return;
const doc = docProp != null ? docProp : document;
const win = (_a = doc == null ? void 0 : doc.defaultView) != null ? _a : window;
const doc = _document != null ? _document : document;
const win = (_a = doc.defaultView) != null ? _a : window;
const { documentElement, body } = doc;
const locked = body.hasAttribute(identifier);
const locked = body.hasAttribute(LOCK_CLASSNAME);
if (locked)
return;
body.setAttribute(identifier, "");
body.setAttribute(LOCK_CLASSNAME, "");
const scrollbarWidth = win.innerWidth - documentElement.clientWidth;

@@ -114,5 +112,4 @@ const setScrollbarWidthProperty = () => setCSSProperty(documentElement, "--scrollbar-width", `${scrollbarWidth}px`);

cleanups.forEach((cleanup) => cleanup());
body.removeAttribute(identifier);
body.removeAttribute(LOCK_CLASSNAME);
};
}
//# sourceMappingURL=index.js.map
{
"name": "@zag-js/remove-scroll",
"version": "0.1.0",
"version": "0.1.1",
"description": "JavaScript utility to remove scroll on body",

@@ -34,3 +34,3 @@ "keywords": [

"dependencies": {
"@zag-js/utils": "0.1.2"
"@zag-js/dom-utils": "0.1.6"
},

@@ -37,0 +37,0 @@ "bugs": {

Sorry, the diff of this file is not supported yet

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