All Projects → some-react-components → React Scrollchor

some-react-components / React Scrollchor

Licence: isc
A React component for scroll to `#hash` links with smooth animations

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Scrollchor

Ngx Page Scroll
Animated scrolling functionality for angular written in pure typescript
Stars: ✭ 422 (+199.29%)
Mutual labels:  animate, scroll
Libchaos
Advanced library for randomization, hashing and statistical analysis (devoted to chaos machines). 🔬
Stars: ✭ 1,619 (+1048.23%)
Mutual labels:  hash
Open Crypto
🔑 Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation.
Stars: ✭ 115 (-18.44%)
Mutual labels:  hash
Merkle
Node.js module implementing Merkle tree algorithm
Stars: ✭ 123 (-12.77%)
Mutual labels:  hash
Digestpp
C++11 header-only message digest library
Stars: ✭ 116 (-17.73%)
Mutual labels:  hash
Mergi
go library for image programming (merge, crop, resize, watermark, animate, ease, transit)
Stars: ✭ 127 (-9.93%)
Mutual labels:  animate
Antidebugging
AntiDebugging sample sources written in C++
Stars: ✭ 114 (-19.15%)
Mutual labels:  hash
Vue Prlx
🔮 Vue.js parallax directive you were looking for (can animate translate & background-position)
Stars: ✭ 140 (-0.71%)
Mutual labels:  scroll
Imagehash
🌄 Perceptual image hashing for PHP
Stars: ✭ 1,744 (+1136.88%)
Mutual labels:  hash
React Text Transition
Animate your text changes
Stars: ✭ 121 (-14.18%)
Mutual labels:  animate
Codetective
a tool to determine the crypto/encoding algorithm used according to traces from its representation
Stars: ✭ 121 (-14.18%)
Mutual labels:  hash
React Simple Animate
🎯 React UI animation made easy
Stars: ✭ 1,626 (+1053.19%)
Mutual labels:  animate
Vue Loaders
Vue + loaders.css
Stars: ✭ 127 (-9.93%)
Mutual labels:  animate
Active hash relation
ActiveHash Relation: Simple gem that allows you to run multiple ActiveRecord::Relation using hash. Perfect for APIs.
Stars: ✭ 115 (-18.44%)
Mutual labels:  hash
Hashlib4pascal
Hashing for Modern Object Pascal
Stars: ✭ 132 (-6.38%)
Mutual labels:  hash
Fim
File Integrity Manager -
Stars: ✭ 114 (-19.15%)
Mutual labels:  hash
Data Structures
Data-Structures using C++.
Stars: ✭ 121 (-14.18%)
Mutual labels:  hash
Password4j
Password4j is a user-friendly cryptographic library that supports Argon2, Bcrypt, Scrypt, PBKDF2 and various cryptographic hash functions.
Stars: ✭ 124 (-12.06%)
Mutual labels:  hash
React Locky
"🔒-y" – Asgardian God of Event Scoping 📦, Scroll Locking 📜, Silence Casting 🙊
Stars: ✭ 141 (+0%)
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 (-1.42%)
Mutual labels:  scroll

react-scrollchor (React Scrollchor)

npm version npm downloads Donate

A React component for scroll to #hash links with smooth animations. Scrollchor is a mix of Scroll and Anchor, a joke name for a useful component.

See it in action:

hash is the id of a HTML tag on current page.

Installation

npm

npm install react-scrollchor --save

Dependencies

  • User should provide their own React package

Usage

import Scrollchor from 'react-scrollchor';
export default (props) => (
  <Page>

    <Navbar brand={brand} className="navbar-fixed-top">
      <NavItem><Scrollchor to="" className="nav-link">Home</Scrollchor></NavItem>
      <NavItem><Scrollchor to="#sample-code" className="nav-link">Sample</Scrollchor></NavItem>
      <NavItem><Scrollchor to="#features" className="nav-link">Features</Scrollchor></NavItem>
      <NavItem><Scrollchor to="footer" className="nav-link">SignUp</Scrollchor></NavItem>
    </Navbar>


  <Section id="sample-code">

  </Section>

  <div id="features">

  </div>

  <footer id="footer">

  </footer>

</Page>

Prop types

  propTypes: {

    /**
     * id attribute of the target DOM node
     * - `#` can be omitted
     * - let it blank, `to = ''`, for scroll to page top
     * - this prop is required
     */
    to: PropTypes.string.isRequired,

    /**
     * id attribute of the scrollable DOM node
     * - `#` can be omitted
     * - uses the root element of the document if omitted
     */
    target: PropTypes.string,

    /**
     * scroll smooth animation can be customized
     * Accepted options, Ex: (default)
     *  { offset: 0, duration: 400, easing: easeOutQuad }
     */
    animate: PropTypes.object,

    /**
     * callback function triggered before scroll to #hash
     * @param1 Received click event
     */
    beforeAnimate: PropTypes.func,

    /**
     * callback function triggered after scroll to #hash
     * @param1 Received click event
     */
    afterAnimate: PropTypes.func

    /**
     * enable/disable update browser history with scroll behaviours
     * Default to `false`
     */
    disableHistory: PropTypes.bool
}

Reactive props

Update props will re-render Scrollchor element

Example: updating "to" prop

Custom animations

Animation behavior can be customized:

<Scrollchor to="#aboutus" animate={{offset: 20, duration: 600}} className="nav-link">Home</Scrollchor>

default animation settings

{ offset: 0, duration: 400, easing: easeOutQuad }

This setting is equivalent to default jQuery.animate easing: swing

more Easing functions

before and after Animate callbacks

Use these callbacks to trigger behaviors like: update state, load async stuff, etc.

<Scrollchor to="#aboutus" afterAnimate={() => updateState(this)}>Home</Scrollchor>

Simulate click API

Scrollchor includes a dedicate API to do animate scroll programmatically that works like normal click events using simulateClick().

Example: using simulateClick

When used programmatically, some use-cases don't need anchor tags. On these cases use childless Scrollchor.

Childless Scrollchor

This component will render null and the user is reponsible for storing the component reference, Ex: childless

<Scrollchor ref={ref => (this._back = ref)} to="_back" />

Example: calling simulateClick() on childless ref

_afterAnimate = () => {
  this.setState({ to: this._iterator.next().value });
    setTimeout(() => this._back.simulateClick(), 1000);
};

Scrollable ancestor container

Scrollchor works within any scrollable parent container. The root element of the document will be choose if none is specified.

Hosted example show how to use a different container using prop target.

  • Click Within scrollable container checkbox: hosted example(full example below)

Full Example

react-scrollchor--example

Credits

author

maintainers

contributors

Contributing

  • Documentation improvement
  • Feel free to send any PR

License

ISC

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