All Projects → theKashey → React Remove Scroll

theKashey / React Remove Scroll

Removes and disables 📜in a "React" way

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Remove Scroll

Jquery Scrolllock
Locks mouse wheel scroll inside container, preventing it from propagating to parent element
Stars: ✭ 109 (-40.11%)
Mutual labels:  scroll
React Scrollchor
A React component for scroll to `#hash` links with smooth animations
Stars: ✭ 141 (-22.53%)
Mutual labels:  scroll
Horizontal Scroll
Horizontal scroll with inertia
Stars: ✭ 175 (-3.85%)
Mutual labels:  scroll
Footer Reveal
A jQuery plugin for easy implementation of the 'fixed/reveal' footer effect. Demo here:
Stars: ✭ 111 (-39.01%)
Mutual labels:  scroll
Vue Prlx
🔮 Vue.js parallax directive you were looking for (can animate translate & background-position)
Stars: ✭ 140 (-23.08%)
Mutual labels:  scroll
Scrollprogress
🛸 Light weight library to observe the viewport scroll position
Stars: ✭ 148 (-18.68%)
Mutual labels:  scroll
Svelte Infinite Scroll
Infinite Scroll Component to Svelte
Stars: ✭ 102 (-43.96%)
Mutual labels:  scroll
Scroll Js
Light cross-browser scroller that uses native javascript
Stars: ✭ 179 (-1.65%)
Mutual labels:  scroll
React Locky
"🔒-y" – Asgardian God of Event Scoping 📦, Scroll Locking 📜, Silence Casting 🙊
Stars: ✭ 141 (-22.53%)
Mutual labels:  scroll
Listloading
listloading是一个移动端的上拉、下拉加载更多的组件。主要依赖于iscroll.js v5.1.2基础上开发的组件,基础库可以使用jquery.js或者zepto.js操作dom节点,目前我是使用了zepto.js作为基础库操作dom,以jquery插件的形式存在。如果不想以插件方式使用,则只需要把listloading直接移植你需要的库里面就ok啦。listloading主要针对移动端而生,在使用浏览器自带滚动,用户体验很不友好,与Android和ios差别甚远,所以选择iscroll.js,它实现方式是使用css3动画translate 3D 转换来实现滚动效果,transform属性使用硬件加速,性能方法得到很大提高。 https://gtdalp.github.io/widget/listloading/demos/listloading.html
Stars: ✭ 169 (-7.14%)
Mutual labels:  scroll
React Scroll Parallax
🔮 React components to create parallax scroll effects for banners, images or any other DOM elements
Stars: ✭ 1,699 (+833.52%)
Mutual labels:  scroll
React Native Directed Scrollview
UNMAINTAINED- see below. A natively implemented scrollview component which lets you specify different scroll directions for child content.
Stars: ✭ 139 (-23.63%)
Mutual labels:  scroll
Unitydynamicscrollrect
An optimized approach to lists with dozens of elements and a Pooling system
Stars: ✭ 157 (-13.74%)
Mutual labels:  scroll
Rolly
Custom scroll with inertia, smooth parallax and scenes manager
Stars: ✭ 109 (-40.11%)
Mutual labels:  scroll
Snappyrecyclerview
An extension to RecyclerView which will snap to child Views to the specified anchor, START, CENTER or END.
Stars: ✭ 178 (-2.2%)
Mutual labels:  scroll
Prognroll
A tiny, lightweight jQuery plugin that creates scroll progress bar on the page.
Stars: ✭ 108 (-40.66%)
Mutual labels:  scroll
Ngx Ui Scroll
Infinite/virtual scroll for Angular
Stars: ✭ 145 (-20.33%)
Mutual labels:  scroll
React Focus On
🎯 Solution for WAI ARIA compatible modal dialogs or full-screen tasks, you were looking for
Stars: ✭ 180 (-1.1%)
Mutual labels:  scroll
Vanilla Back To Top
Simple and smooth Back To Top button
Stars: ✭ 179 (-1.65%)
Mutual labels:  scroll
Emergence.js
Detect element visibility in the browser
Stars: ✭ 1,891 (+939.01%)
Mutual labels:  scroll

React-remove-📜


dont even scroll
Build status npm downloads bundle size

react-remove-scroll

NPM version

Disables scroll outside of children node.

  • 🖱 mouse and touch devices friendly
  • 📈 vertical and horizontal
  • 📜 removes document scroll bar maintaining it space
  • ✅ support nested scrollable elements
  • 🕳 supports react-portals (uses React Event system)
  • ☠️ it could block literally any scroll anywhere

Usage

Just wrap content, which should be scrollable, and everything else would not.

import {RemoveScroll} from 'react-remove-scroll';

<RemoveScroll>
  Only this content would be scrollable
</RemoveScroll>  

RemoveScroll accept following props

  • children
  • [enabled] - activate or deactivate component behaviour without removing it.
  • [allowPinchZoom=false] - enabled "pinch-n-zoom" behavior. By default it might be prevented. However - pinch and zoom might break "scroll isolation", and disabled by default.
  • [noIsolation=false] - disables outer event capturing. Event capturing is React friendly and unlikely be a problem. But if you are using shadowbox of some sort - you dont need it.
  • [inert=false] - ☠️(be careful) disables events the rest of page completely using pointer-events except the Lock(+shards). React portals not friendly, might lead to production issues. Enable only for rare cases, when you have to disable scrollbars somewhere on the page(except body, Lock and shards).
  • [forwardProps] - will forward all props to the children
  • [className] - className for an internal div
  • [removeScrollBar] - to control scroll bar removal. Set to false, if you prefer to keep it (wheel and touch scroll is still disabled).

Size

  • (🧩 full) 1.7kb after compression (excluding tslib).

  • (👁 UI) 400b, visual elements only
  • (🚗 sidecar) 1.5kb, side effects
import {sidecar} from "react-remove-scroll";
import {RemoveScroll} from 'react-remove-scroll/UI';

const sidecar = sidecar(() => import('react-remove-scroll/sidecar'));

<RemoveScroll sideCar={sidecar}>
  Will load logic from a sidecar when needed
</RemoveScroll>  

Consider setting -webkit-overflow-scrolling: touch; on a document level for a proper mobile experience.

Internal div

But default RemoveScroll will create a div to handle and capture events. You may specify className for it, if you need, or remove it.

The following code samples will produce the same output

<RemoveScroll className="scroll">
  Only this content would be scrollable
</RemoveScroll>
<RemoveScroll forwardProps>
  <div className="scroll"> //RemoveScroll will inject props to this div
    Only this content would be scrollable
  </div>
</RemoveScroll> 

Pick the first one if you don't need a second.

Position:fixed elements

To properly size these elements please add a special className to them.

import {RemoveScroll} from 'react-remove-scroll';

// to make "width: 100%"
<div className={cx(classWithPositionFixed, RemoveScroll.classNames.fullWidth)} />

// to make "right:0"
<div className={cx(classWithPositionFixed, RemoveScroll.classNames.zeroRight)} />

See react-remove-scroll-bar documentation for details.

More than one lock

When stacked more is active (default) only one (last) component would be active.

Over isolation

That could happen - you disable scroll on the body, you are suppressing all scroll and wheel events, and you are ghosting the rest of the page by the inert prop.

Only something inside Lock does exists for the browser, and that might be less than you expected.

Dont forget about shard, dont forget - inert is not portals friendly, dont forget - you dont need over isolation in most of the cases.

just be careful!

Performance

To do the job this library setup non passive event listener. Chrome dev tools would complain about it, as a performance no-op.

We have to use synchronous scroll/touch handler, and it may affect scrolling performance.

Consider using noIsolation mode, if you have large scrollable areas.

Supported React versions

  • v1 supports React 15/16
  • v2 requires 16.8.0+ (hooks)

Scroll-Locky

This is a refactoring of another library - react-scroll-locky - to make package smaller and more react-portals friendly.

See also

This package is relative smaller(1), more react friendly(2), works with non zero body margins(3), and has a better "overscroll" management.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].