All Projects β†’ theKashey β†’ react-scroll-locky

theKashey / react-scroll-locky

Licence: other
πŸ“œπŸ”’ – React full-cream "anti-scroll" library, you were looking for

Programming Languages

typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to react-scroll-locky

mousecase
A JavaScript utility enabling horizontal dragging on mousedown events πŸ–±
Stars: ✭ 35 (-36.36%)
Mutual labels:  scrolling, scrollbar
react-custom-scroller
Super simple React component for creating a custom scrollbar cross-browser and cross-devices.
Stars: ✭ 30 (-45.45%)
Mutual labels:  scrolling, scrollbar
ng-scrollable
Superamazing scrollbars for AngularJS
Stars: ✭ 58 (+5.45%)
Mutual labels:  scrolling, scrollbar
V Bar
The virtual responsive crossbrowser scrollbar component for VueJS 2x
Stars: ✭ 216 (+292.73%)
Mutual labels:  scrolling, scrollbar
react-is-scrolling
Simply detect if users are scrolling in your components in a declarative API
Stars: ✭ 17 (-69.09%)
Mutual labels:  scrolling, scrollbar
Scrollinglettersanimation
A switching title effect where a fixed element changes depending on the scroll position.
Stars: ✭ 197 (+258.18%)
Mutual labels:  scrolling
Scrollstory
A jQuery plugin for building scroll-based stories
Stars: ✭ 249 (+352.73%)
Mutual labels:  scrolling
React Indiana Drag Scroll
React component which implements scrolling via holding the mouse button or touch
Stars: ✭ 190 (+245.45%)
Mutual labels:  scrolling
Md max72xx
LED Matrix Library
Stars: ✭ 186 (+238.18%)
Mutual labels:  scrolling
render-props
㸚 Easy-to-use React state containers which utilize the render props (function as child) pattern
Stars: ✭ 33 (-40%)
Mutual labels:  scrolling
MHScrollingHeader
An Easy Way to Intergate Scrolling Header
Stars: ✭ 13 (-76.36%)
Mutual labels:  scrolling
Smoothscrollanimations
Demo of a tutorial on how to add smooth page scrolling with an inner image animation
Stars: ✭ 238 (+332.73%)
Mutual labels:  scrolling
Priority Nav Scroller
Priority Nav Scroller is a plugin for the priority+ navigation pattern.
Stars: ✭ 198 (+260%)
Mutual labels:  scrolling
Moveto
A lightweight scroll animation javascript library without any dependency
Stars: ✭ 2,746 (+4892.73%)
Mutual labels:  scrolling
Stickyfill
Polyfill for CSS `position: sticky`
Stars: ✭ 2,252 (+3994.55%)
Mutual labels:  scrolling
body-scroll-freezer
↕️ Dependency-free JS module to freeze body scroll when opening modal box
Stars: ✭ 22 (-60%)
Mutual labels:  scrolling
Scroll Snap
β†― Snap page when user stops scrolling, with a customizable configuration and a consistent cross browser behaviour
Stars: ✭ 187 (+240%)
Mutual labels:  scrolling
angular-inviewport
A simple lightweight library for Angular with no other dependencies that detects when an element is within the browser viewport and adds a "sn-viewport-in" or "sn-viewport-out" class to the element
Stars: ✭ 72 (+30.91%)
Mutual labels:  scrolling
Hiddensearchwithrecyclerview
Simple library to have a hidden/shown search bar
Stars: ✭ 220 (+300%)
Mutual labels:  scrolling
Vue Product Zoomer
Zoom Prodct Image, useful for e-shop website
Stars: ✭ 248 (+350.91%)
Mutual labels:  scrolling

πŸ’€ react-scroll-locky was replaced by react-remove-scroll πŸ’€

πŸ“œπŸ”’ react-scroll-locky


πŸ“œ Prevents page from being scrolled. Or any other "not permitted" container.

πŸ’‘ Hides scrollbars, preserving page width.

🀘 Works on any desktop or mobile browser.

πŸ“¦ All features are hidden inside.

πŸ‘« Stands more that one instance.

πŸ€” Supports nested locks

πŸ”₯ Supports nested scrollable elements.

Just wrap your content with <ScrollLocky /> and it block any iterations with the rest of a page.

This is one line solution for the problem.

All due to React-Locky it uses underneath

this could be dangerous for focus state management. Consider use more composite library - react-focus-on - to handle the every edge case.

  • focus
  • scroll
  • aria (inert)

PS

I've create react-remove-scroll - a smaller version of this library.

API

Just wrap anything with ScrollLocky, which accepts only one prop - "enabled"

There is only a few pros to configure

  • noRelative - do not apply "position:relative" on body.
  • noImportant - do not apply "!important" to any rules.
  • className - className for a internal div
  • headless - enables "no-div" mode (will pick the first DOM node-inside)
  • enabled - allows to disable Lock behavior (CSS modification and Locky), keeping it rendered.
  • isolation - allows to disable event isolation, preventing only scroll events, not everything outside target node (default behaviour). Use isolation:false if you have some "shadow" underneath modal, to catch and redirect all events.
  • gapMode=[padding|margin(default)] - gap policy, to control the way scrollLocky generate the gap instead of scrollbars. This option affects how absolutely positioned elements will work:
    • gapMode="padding" - "right:0" will be on window right (will jump on scroll removal)
    • gapMode="margin" - "right:0" will be in constant position (will not jump, but leave a gap)
import {ScrollLocky} from 'react-scroll-locky';

<Modal>
 <ScrollLocky>
   <MyContent>
     Anything!
   </MyContent>
 </ScrollLocky>
</Modal>   

Hide scrollbars only

To hide body scrollbars only (does not disable scroll on scrollable container, or body scroll on iOS) use HideBodyScroll component

import {HideBodyScroll} from 'react-scroll-locky';

<HideBodyScroll noRelative noImportant gapMode/> // body scrollbar is hidden

The order

You may have more than one active Lock on the page:

  • Only first Lock is real. Only it hides the scrollbars.
  • Only the last Lock is active. Only last-mounted Locky is working, silencing the rest of a page.
  • To have more that one active lock - consider using HideBodyScroll + react-locky directly.

Gap modes

  • "padding" - for the simple use. It will keep scroll-bar-gap for the normal elements, letting absolutely or fixed positioned elements hit the right-most window edge.
  • "margin" - for the advanced use. Will always preserve the gap, letting only the fixed positioned elements fill the while page(preffered mode)

Default Gap Mode is "margin", it would fit for almost anyone. But if you have another margin on your body (please dont), or have width:100% on the body - it would not.

Then, and only then use gapMode="padding", and dont forget to add box-sizing: border-box; to include paddings, we are going to set, to your width. (and don't send paddings on body, then).

To fill the gap with absolute positioned elements - use another exposed component.

Special component - ScrollLockyPane will help maintain the right "right" position. Alternatively - use react-scroll-locky-edge-right class, to set proper right border for a container.

import {ScrollLocky, ScrollLockyPane} from 'react-scroll-locky';

// position:absolute, left:0, right: -"gap"px
<ScrollLockyPane>
  // your modal inside
  <Modal>
     <ScrollLocky>
        <MyContent/>  
     </ScrollLocky>
  </Modal> 
</ScrollLockyPane>

ScrollLockyPane will "return" the "consumed" width to the component.

Multiple locks

  • If you need multiple locks to be active in a same time - just do it. They will work together.

Article

There is a medium article about preventing the body scroll - How to fight the scroll

More

For a good modals you also need a proper Focus Management Library. Use react-focus-lock to complete the picture.

See also

Licence

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].