Initial commit
This commit is contained in:
13
node_modules/react-remove-scroll-bar/dist/es2015/component.d.ts
generated
vendored
Normal file
13
node_modules/react-remove-scroll-bar/dist/es2015/component.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import { GapMode } from './utils';
|
||||
export interface BodyScroll {
|
||||
noRelative?: boolean;
|
||||
noImportant?: boolean;
|
||||
gapMode?: GapMode;
|
||||
}
|
||||
export declare const lockAttribute = "data-scroll-locked";
|
||||
export declare const useLockAttribute: () => void;
|
||||
/**
|
||||
* Removes page scrollbar and blocks page scroll when mounted
|
||||
*/
|
||||
export declare const RemoveScrollBar: React.FC<BodyScroll>;
|
||||
53
node_modules/react-remove-scroll-bar/dist/es2015/component.js
generated
vendored
Normal file
53
node_modules/react-remove-scroll-bar/dist/es2015/component.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
import * as React from 'react';
|
||||
import { styleSingleton } from 'react-style-singleton';
|
||||
import { fullWidthClassName, zeroRightClassName, noScrollbarsClassName, removedBarSizeVariable } from './constants';
|
||||
import { getGapWidth } from './utils';
|
||||
var Style = styleSingleton();
|
||||
export var lockAttribute = 'data-scroll-locked';
|
||||
// important tip - once we measure scrollBar width and remove them
|
||||
// we could not repeat this operation
|
||||
// thus we are using style-singleton - only the first "yet correct" style will be applied.
|
||||
var getStyles = function (_a, allowRelative, gapMode, important) {
|
||||
var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
|
||||
if (gapMode === void 0) { gapMode = 'margin'; }
|
||||
return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
|
||||
allowRelative && "position: relative ".concat(important, ";"),
|
||||
gapMode === 'margin' &&
|
||||
"\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
|
||||
gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
|
||||
};
|
||||
var getCurrentUseCounter = function () {
|
||||
var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
|
||||
return isFinite(counter) ? counter : 0;
|
||||
};
|
||||
export var useLockAttribute = function () {
|
||||
React.useEffect(function () {
|
||||
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
||||
return function () {
|
||||
var newCounter = getCurrentUseCounter() - 1;
|
||||
if (newCounter <= 0) {
|
||||
document.body.removeAttribute(lockAttribute);
|
||||
}
|
||||
else {
|
||||
document.body.setAttribute(lockAttribute, newCounter.toString());
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
};
|
||||
/**
|
||||
* Removes page scrollbar and blocks page scroll when mounted
|
||||
*/
|
||||
export var RemoveScrollBar = function (_a) {
|
||||
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
|
||||
useLockAttribute();
|
||||
/*
|
||||
gap will be measured on every component mount
|
||||
however it will be used only by the "first" invocation
|
||||
due to singleton nature of <Style
|
||||
*/
|
||||
var gap = React.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
|
||||
return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
|
||||
};
|
||||
8
node_modules/react-remove-scroll-bar/dist/es2015/constants.d.ts
generated
vendored
Normal file
8
node_modules/react-remove-scroll-bar/dist/es2015/constants.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export declare const zeroRightClassName = "right-scroll-bar-position";
|
||||
export declare const fullWidthClassName = "width-before-scroll-bar";
|
||||
export declare const noScrollbarsClassName = "with-scroll-bars-hidden";
|
||||
/**
|
||||
* Name of a CSS variable containing the amount of "hidden" scrollbar
|
||||
* ! might be undefined ! use will fallback!
|
||||
*/
|
||||
export declare const removedBarSizeVariable = "--removed-body-scroll-bar-size";
|
||||
8
node_modules/react-remove-scroll-bar/dist/es2015/constants.js
generated
vendored
Normal file
8
node_modules/react-remove-scroll-bar/dist/es2015/constants.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export var zeroRightClassName = 'right-scroll-bar-position';
|
||||
export var fullWidthClassName = 'width-before-scroll-bar';
|
||||
export var noScrollbarsClassName = 'with-scroll-bars-hidden';
|
||||
/**
|
||||
* Name of a CSS variable containing the amount of "hidden" scrollbar
|
||||
* ! might be undefined ! use will fallback!
|
||||
*/
|
||||
export var removedBarSizeVariable = '--removed-body-scroll-bar-size';
|
||||
4
node_modules/react-remove-scroll-bar/dist/es2015/index.d.ts
generated
vendored
Normal file
4
node_modules/react-remove-scroll-bar/dist/es2015/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { RemoveScrollBar } from './component';
|
||||
import { zeroRightClassName, fullWidthClassName, noScrollbarsClassName, removedBarSizeVariable } from './constants';
|
||||
import { getGapWidth } from './utils';
|
||||
export { RemoveScrollBar, zeroRightClassName, fullWidthClassName, noScrollbarsClassName, removedBarSizeVariable, getGapWidth, };
|
||||
4
node_modules/react-remove-scroll-bar/dist/es2015/index.js
generated
vendored
Normal file
4
node_modules/react-remove-scroll-bar/dist/es2015/index.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { RemoveScrollBar } from './component';
|
||||
import { zeroRightClassName, fullWidthClassName, noScrollbarsClassName, removedBarSizeVariable } from './constants';
|
||||
import { getGapWidth } from './utils';
|
||||
export { RemoveScrollBar, zeroRightClassName, fullWidthClassName, noScrollbarsClassName, removedBarSizeVariable, getGapWidth, };
|
||||
14
node_modules/react-remove-scroll-bar/dist/es2015/utils.d.ts
generated
vendored
Normal file
14
node_modules/react-remove-scroll-bar/dist/es2015/utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
export declare type GapMode = 'padding' | 'margin';
|
||||
export interface GapOffset {
|
||||
left: number;
|
||||
top: number;
|
||||
right: number;
|
||||
gap: number;
|
||||
}
|
||||
export declare const zeroGap: {
|
||||
left: number;
|
||||
top: number;
|
||||
right: number;
|
||||
gap: number;
|
||||
};
|
||||
export declare const getGapWidth: (gapMode?: GapMode) => GapOffset;
|
||||
29
node_modules/react-remove-scroll-bar/dist/es2015/utils.js
generated
vendored
Normal file
29
node_modules/react-remove-scroll-bar/dist/es2015/utils.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
export var zeroGap = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
gap: 0,
|
||||
};
|
||||
var parse = function (x) { return parseInt(x || '', 10) || 0; };
|
||||
var getOffset = function (gapMode) {
|
||||
var cs = window.getComputedStyle(document.body);
|
||||
var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
|
||||
var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
|
||||
var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
|
||||
return [parse(left), parse(top), parse(right)];
|
||||
};
|
||||
export var getGapWidth = function (gapMode) {
|
||||
if (gapMode === void 0) { gapMode = 'margin'; }
|
||||
if (typeof window === 'undefined') {
|
||||
return zeroGap;
|
||||
}
|
||||
var offsets = getOffset(gapMode);
|
||||
var documentWidth = document.documentElement.clientWidth;
|
||||
var windowWidth = window.innerWidth;
|
||||
return {
|
||||
left: offsets[0],
|
||||
top: offsets[1],
|
||||
right: offsets[2],
|
||||
gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user