Coder Social home page Coder Social logo

react-scroll's Introduction

React Scroll

React component for animating vertical scrolling

Table of Contents

Introduction

React-Scroll is a lightweight library for enhancing scrolling functionality in React applications. Whether you're building a single-page application, a portfolio site, or a complex web application, React Scroll provides you with an easy-to-use solution for implementing smooth scrolling behavior. This works with the latest versions of Google Chrome, Microsodt Edge, and Firefox.

Features

  • Smooth Scrolling: Achieve seamless scrolling animations between sections of your web page.
  • Customization: Customize scroll behavior to suit your application's design and user experience requirements.
  • Accessibility: Ensure your scrolling functionality is accessible to all users, including those who rely on assistive technologies.
  • Lightweight: Keep your bundle size small with React Scroll's minimal footprint.

Install

$ npm install react-scroll

or

$ yarn add react-scroll

Run

$ npm install
$ npm test
$ npm start

or

$ yarn
$ yarn test
$ yarn start

Examples

Checkout examples

Live example

Basic

Basic-Keydown

Container

With-hash

With-overflow

Code

Code example

Next.js

Example of Using react-scroll with image and detailed explanation!

In this example, the react-scroll library was utilized to enable smooth scrolling navigation within a single-page React application. The library provides components such as Link and Element that facilitate seamless navigation between different sections of the page. Once you start your react app, you can add this code at the bottom to experience the scroll feature!

Code:

import React from 'react';
import { Link, Element } from 'react-scroll';

function App() {
  return (
    <div>
      <nav>
        <ul>
          <li>
            <Link to="section1" smooth={true} duration={500}>Section 1</Link>
          </li>
          <li>
            <Link to="section2" smooth={true} duration={500}>Section 2</Link>
          </li>
          {/* Add more navigation links as needed */}
        </ul>
      </nav>
      <Element name="section1">
        <section style={{ height: '100vh', backgroundColor: 'lightblue' }}>
          <h1>Section 1</h1>
          <p>This is the content of section 1</p>
        </section>
      </Element>
      <Element name="section2">
        <section style={{ height: '100vh', backgroundColor: 'lightgreen' }}>
          <h1>Section 2</h1>
          <p>This is the content of section 2</p>
        </section>
      </Element>
      {/* Add more sections with Element components as needed */}
    </div>
  );
}

export default App;

GIF_example

Usage

import React, { useEffect } from 'react';
import { Link, Button, Element, Events, animateScroll as scroll, scrollSpy } from 'react-scroll';

const Section = () => {

  // useEffect is used to perform side effects in functional components.
  // Here, it's used to register scroll events and update scrollSpy when the component mounts.
  useEffect(() => {
    
    // Registering the 'begin' event and logging it to the console when triggered.
    Events.scrollEvent.register('begin', (to, element) => {
      console.log('begin', to, element);
    });

    // Registering the 'end' event and logging it to the console when triggered.
    Events.scrollEvent.register('end', (to, element) => {
      console.log('end', to, element);
    });

    // Updating scrollSpy when the component mounts.
    scrollSpy.update();

    // Returning a cleanup function to remove the registered events when the component unmounts.
    return () => {
      Events.scrollEvent.remove('begin');
      Events.scrollEvent.remove('end');
    };
  }, []);

  // Defining functions to perform different types of scrolling.
  const scrollToTop = () => {
    scroll.scrollToTop();
  };

  const scrollToBottom = () => {
    scroll.scrollToBottom();
  };

  const scrollTo = () => {
    scroll.scrollTo(100); // Scrolling to 100px from the top of the page.
  };

  const scrollMore = () => {
    scroll.scrollMore(100); // Scrolling an additional 100px from the current scroll position.
  };

  // Function to handle the activation of a link.
  const handleSetActive = (to) => {
    console.log(to);
  };

  // Rendering the component's JSX.
  return (
  <div>
    {/* Link component to scroll to "test1" element with specified properties */}
    <Link 
      activeClass="active" 
      to="test1" 
      spy={true} 
      smooth={true} 
      offset={50} 
      duration={500} 
      onSetActive={handleSetActive}
    >
      Test 1
    </Link>

    {/* Other Link and Button components for navigation, each with their unique properties and targets */}
    {/* ... */}

    {/* Element components that act as scroll targets */}
    <Element name="test1" className="element">
      test 1
    </Element>
    <Element name="test2" className="element">
      test 2
    </Element>
    <div id="anchor" className="element">
      test 6 (anchor)
    </div>

    {/* Links to elements inside a specific container */}
    <Link to="firstInsideContainer" containerId="containerElement">
      Go to first element inside container
    </Link>
    <Link to="secondInsideContainer" containerId="containerElement">
      Go to second element inside container
    </Link>

    {/* Container with elements inside */}
    <div className="element" id="containerElement">
      <Element name="firstInsideContainer">
        first element inside container
      </Element>
      <Element name="secondInsideContainer">
        second element inside container
      </Element>
    </div>

    {/* Anchors to trigger scroll actions */}
    <a onClick={scrollToTop}>To the top!</a>
    <br/>
    <a onClick={scrollToBottom}>To the bottom!</a>
    <br/>
    <a onClick={scrollTo}>Scroll to 100px from the top</a>
    <br/>
    <a onClick={scrollMore}>Scroll 100px more from the current position!</a>
  </div>
);

};

export default Section;

Props/Options

activeClass class applied when element is reached
activeStyle style applied when element is reached
to Target to scroll to
containerId Container to listen for scroll events and to perform scrolling in
spy Make Link selected when scroll is at its targets position
hashSpy Update hash based on spy, containerId has to be set to scroll a specific element
smooth Animate the scrolling
offset Scroll additional px ( like padding )
duration time of the scroll animation - can be a number or a function (`function (scrollDistanceInPx) { return duration; }`), that allows more granular control at run-time
delay Wait x milliseconds before scroll
isDynamic In case the distance has to be recalculated - if you have content that expands etc.
onSetActive Invoke whenever link is being set to active
onSetInactive Invoke whenever link is lose the active status
ignoreCancelEvents Ignores events which cancel animated scrolling
horizontal Whether to scroll vertically (`false`) or horizontally (`true`) - default: `false`
spyThrottle Time of the spy throttle - can be a number

Full example

<Link activeClass="active"
      to="target"
      spy={true}
      smooth={true}
      hashSpy={true}
      offset={50}
      duration={500}
      delay={1000}
      isDynamic={true}
      onSetActive={this.handleSetActive}
      onSetInactive={this.handleSetInactive}
      ignoreCancelEvents={false}
      spyThrottle={500}
>
  Your name
</Link>

Scroll Methods

Scroll To Top

import { animateScroll } from 'react-scroll';

const options = {
  // your options here, for example:
  duration: 500,
  smooth: true,
};

animateScroll.scrollToTop(options);

Scroll To Bottom

import { animateScroll } from 'react-scroll';

const options = {
  // Your options here, for example:
  duration: 500,
  smooth: true,
};

animateScroll.scrollToBottom(options);

Scroll To (position)

import { animateScroll } from 'react-scroll';

const options = {
  // Your options here, for example:
  duration: 500,
  smooth: true,
};

// Scroll to 100 pixels from the top of the page
animateScroll.scrollTo(100, options);

Scroll To (Element)

animateScroll.scrollTo(positionInPixels, props = {});

import { Element, scroller } from 'react-scroll';

<Element name="myScrollToElement"></Element>

// Somewhere else, even another file
scroller.scrollTo('myScrollToElement', {
  duration: 1500,
  delay: 100,
  smooth: true,
  containerId: 'ContainerElementID',
  offset: 50, // Scrolls to element + 50 pixels down the page
  // ... other options
});

Scroll More (px)

import { animateScroll } from 'react-scroll';

const options = {
  // Your options here, for example:
  duration: 500,
  smooth: true,
};

// Scroll an additional 10 pixels down from the current scroll position
animateScroll.scrollMore(10, options);

Scroll events

begin - start of the scrolling

import { Events } from 'react-scroll';

Events.scrollEvent.register('begin', function(to, element) {
  console.log('begin', to, element);
});

end - end of the scrolling/animation

import { Events } from 'react-scroll';

Events.scrollEvent.register('end', function(to, element) {
  console.log('end', to, element);
});

Remove events

import { Events } from 'react-scroll';

Events.scrollEvent.remove('begin');
Events.scrollEvent.remove('end');

Create your own Link/Element

Simply just pass your component to one of the high order components (Element/Scroll)

import React from 'react';
import { ScrollElement, ScrollLink } from 'react-scroll';

const Element = (props) => {
  return (
    <div {...props} ref={(el) => { props.parentBindings.domNode = el; }}>
      {props.children}
    </div>
  );
};

export const ScrollableElement = ScrollElement(Element);

const Link = (props) => {
  return (
    <a {...props}>
      {props.children}
    </a>
  );
};

export const ScrollableLink = ScrollLink(Link);

Scroll Animations

Add a custom easing animation to the smooth option. This prop will accept a Boolean if you want the default, or any of the animations listed below

import { scroller } from 'react-scroll';

scroller.scrollTo('myScrollToElement', {
  duration: 1500,
  delay: 100,
  smooth: 'easeInOutQuint',
  containerId: 'ContainerElementID',
  // ... other options
});

List of currently available animations:

linear
	- no easing, no acceleration.
easeInQuad
	- accelerating from zero velocity.
easeOutQuad
	- decelerating to zero velocity.
easeInOutQuad
	- acceleration until halfway, then deceleration.
easeInCubic
	- accelerating from zero velocity.
easeOutCubic
	- decelerating to zero velocity.
easeInOutCubic
	- acceleration until halfway, then deceleration.
easeInQuart
	- accelerating from zero velocity.
easeOutQuart
	- decelerating to zero velocity.
easeInOutQuart
	-  acceleration until halfway, then deceleration.
easeInQuint
	- accelerating from zero velocity.
easeOutQuint
	- decelerating to zero velocity.
easeInOutQuint
	- acceleration until halfway, then deceleration.

A good visual reference can be found at easings.net

Best Practices and Tips

  • Optimize performance by limiting the number of elements with scroll events.
  • Test your application on various devices and screen sizes to ensure accessibility.

Troubleshooting and FAQs

  • Q: How do I customize the scroll behavior?

  • A: You can customize the scroll duration, easing function, and other parameters using the duration, smooth, and offset props.

  • Q: Why is my smooth scrolling not working? This can be applied to any prop!

  • A: Ensure that the smooth prop is set to true and that your browser supports smooth scrolling.

Contributions

  • To contribute to React-Scroll, please follow these guidelines:

  • Fork the repository and create a new branch for your changes.

  • Make your changes and submit a pull request with a clear description of your work.

  • Include tests and ensure all existing tests pass before submitting your changes.

Changelog

License

react-scroll's People

Contributors

andreasklinger avatar antipin avatar borunovm avatar chelorope avatar colindresj avatar dahlie avatar dapi avatar daviferreira avatar devfishy avatar fisshy avatar genod avatar ipradyumnadebnath avatar joemcbride avatar kinging123 avatar malthejorgensen avatar maximus1108 avatar nutgaard avatar philhack avatar piscis avatar rikukissa avatar serjobas avatar seungdeng17 avatar sfrdmn avatar sjmulder avatar slashtu avatar sleexyz avatar smirnovw avatar therippa avatar xodder avatar yoiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-scroll's Issues

Cannot render on server-side

Im trying to render application on server-side with React.renderToString method
https://github.com/mhart/react-server-example
and have got an error:

e:\repos\wt-site\node_modules\react-scroll\lib\mixins\cancel-events.js:6
            document.addEventListener(events[i], cancelEvent);
            ^
ReferenceError: document is not defined
    at Object.module.exports.register (e:\repos\wt-site\node_modules\react-scroll\lib\mixins\cancel-events.js:6:4)
    at Object.<anonymous> (e:\repos\wt-site\node_modules\react-scroll\lib\mixins\animate-scroll.js:11:14)
    at Module._compile (module.js:456:26)
    at Object.require.extensions.(anonymous function) [as .js] (e:\repos\wt-site\node_modules\node-jsx\index.js:26:12)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (e:\repos\wt-site\node_modules\react-scroll\lib\mixins\Helpers.js:4:21)
    at Module._compile (module.js:456:26)

Not activating link

In Helpers.js there's a code on line 75 which determines if link needs to be active. I added console log there like so

if(offsetY >= top && offsetY <= height && scroller.getActiveLink() != to) {
            console.log("yes", to)
            scroller.setActiveLink(to);

If I click a link and it scrolls to element top to bottom, then the value of "to" is wrong, but as I scroll just one pixel it is calling it again with correct "to" value. So my link doesn't get active class unless i scroll a little bit.

Surprisingly this is not the case when I am at the bottom of a page and scroll bottom to top by pressing on link

initial selection

How to set initial selection ? In demo page, tab "Test 1" should be selected.

I try to modify getInitialSate in Link.js

getInitialState : function() {
return { active : this.props.defaultSelected? true : false};
}

Unknown props spy, smooth, duration on <a> tag

Hi, I get a warning when I update my react version to 15.2.0.

Warning: Unknown props `spy`, `smooth`, `duration` on <a> tag. Remove these props from the element

I use "Link", "Element" to scroll my screen.

Thank you.

Meteor has conflict with react-dom npm

Hello,

I ran into a problem trying to use react-scroll in Meteor. The problem is that the react-scroll uses a react-dom npm as dependency, which is not in "Meteor". As a result, when you try to connect react-scroll to a component, an error appears:
post_image2

`unmount` should remove specific references of callbacks instead of clearing the stack

When using react router and ReactTransitionGroup, the componentDidMount of the incoming view gets called before the componentWillUnmount of the outgoing view is called. This results in the callbacks added by the new view being cleared when the old component leaves.

The Helpers.js mixin should keep references to the callbacks passed to scrollSpy, and pass those as arguments into scrollSpy.unmount(), and scrollSpy's unmount would need to accept those arguments and slice them out of the array instead of clearing the entire array.

https://github.com/fisshy/react-scroll/blob/master/modules/mixins/scroll-spy.js#L40-L41

this.spyCallbacks = [];
this.spySetState = [];

the above should be turned into something like

this.spyCallbacks.splice(this.spyCallbacks.indexOf(spyCallbackToRemove), 1);
this.spySetState.splice(this.spySetState.indexOf(spySetStateToRemove), 1);

Unknown prop `smooth`

There is something happening with the <Link /> tag for me. What is this causing? Without the smooth attribute, the scroll isn't happening .. well, smooth...

warning.js:44 Warning: Unknown prop `smooth` on <a> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop

Seems working fine, but got warnings when scrolling

Anyone has encountered this before?

input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null.

warning @   warning.js:45
assertValidProps    @   ReactDOMComponent.js:200
ReactDOMComponent.Mixin.updateComponent @   ReactDOMComponent.js:698
ReactDOMComponent.Mixin.receiveComponent    @   ReactDOMComponent.js:645
ReactReconciler.receiveComponent    @   ReactReconciler.js:87
ReactCompositeComponentMixin._updateRenderedComponent   @   ReactCompositeComponent.js:562
ReactCompositeComponentMixin._performComponentUpdate    @   ReactCompositeComponent.js:544
ReactCompositeComponentMixin.updateComponent    @   ReactCompositeComponent.js:473
ReactCompositeComponent_updateComponent @   ReactPerf.js:66
ReactCompositeComponentMixin.receiveComponent   @   ReactCompositeComponent.js:405
ReactReconciler.receiveComponent    @   ReactReconciler.js:87
ReactCompositeComponentMixin._updateRenderedComponent   @   ReactCompositeComponent.js:562
ReactCompositeComponentMixin._performComponentUpdate    @   ReactCompositeComponent.js:544
ReactCompositeComponentMixin.updateComponent    @   ReactCompositeComponent.js:473
ReactCompositeComponent_updateComponent @   ReactPerf.js:66
ReactCompositeComponentMixin.performUpdateIfNecessary   @   ReactCompositeComponent.js:421
ReactReconciler.performUpdateIfNecessary    @   ReactReconciler.js:102
runBatchedUpdates   @   ReactUpdates.js:129
Mixin.perform   @   Transaction.js:136
Mixin.perform   @   Transaction.js:136
assign.perform  @   ReactUpdates.js:86
flushBatchedUpdates @   ReactUpdates.js:147
ReactUpdates_flushBatchedUpdates    @   ReactPerf.js:66
Mixin.closeAll  @   Transaction.js:202
Mixin.perform   @   Transaction.js:149
ReactDefaultBatchingStrategy.batchedUpdates @   ReactDefaultBatchingStrategy.js:62
enqueueUpdate   @   ReactUpdates.js:176
enqueueUpdate   @   ReactUpdateQueue.js:24
ReactUpdateQueue.enqueueSetState    @   ReactUpdateQueue.js:190
ReactComponent.setState @   ReactComponent.js:65
(anonymous function)    @   Helpers.js:100
scrollSpy.updateStates  @   scroll-spy.js:36
(anonymous function)    @   Helpers.js:131
scrollSpy.scrollHandler @   scroll-spy.js:20

Scroll if not visible

Hi I'm thinking it would be useful to have a flag to only scroll if the element you are scrolling to isn't visible.

Are you into the idea? If so I could make a pull request.

Make possible to calculate elemBottomBound based on next <Element> elemTopBound

Hey, thanks for useful lib. I wondering if you can cover such use-case: presume that I have y-'gaps' between my <Element>s on the page. If I scroll over first <Element>, it makes corresponding active. However, if I'm currently 'between' <Element>s, meaning rectBound of neither first element's on z-axis nor second element's on z-axis is inside scrollTop coordinate, _neither first or second is active.

More 'real' use case: I have elements that are at the middle of page, but I want first to be active even when I'm on top of the page so user sees that she's looking at first element of my content. By layout/css consideration I can't wrap whole my page in .

Hope this explanation makes sense.

Thanks!

scrollSpy performs unnecessary work

Seems like the mount method in scroll-spy.js is getting called every time a <Link .../> is mounted, resulting in multiple scroll listeners on document. Since scrollSpy is a global singleton which manages its own listeners, there should be a check which only adds the scroll listener if there is none already

I'll probably up a PR for this, unless I'm misreading the whole thing

Smooth Scrolling isn't working

Not sure whats up, probably something with my code.. when i click a Link element it just hops right to that element and doesnt do smooth scrolling...

anyone have any ideas?

Dependencies not being installed via npm

I'm trying to integrate this package with npm, but your dependencies aren't being installed through npm install. I notice this based on the logs, but here's an example error I get from webpack.

ERROR in ./~/react-scroll/lib/mixins/animate-scroll.js
Module not found: Error: Cannot resolve module 'object-assign' in /js/directory/node_modules/react-scroll/lib/mixins
 @ ./~/react-scroll/lib/mixins/animate-scroll.js 3:13-37

I notice there are no dependencies in the package.json in the build/npm folder either.

scrollTo doesn't works passing a object as second parameter

scroller.scrollTo function doesn't works using an object as props:

    scroller.scrollTo(target, { offset: 100, smooth: true });

Looking around the compiled code I've checked the code, and the scrollTo method expect the these parameters: (to, animate, duration, offset). So, when I tried to use the exactly match it's works fine:

    scroller.scrollTo(hashTarget, true, false, -120);

I'm using the 1.0.4 library version and have no idea where I could find the releases documentation.

Feel free to close this issue if this doesn't makes any sense, otherwise I think is necessary to update the documentation.

Best regards!

Babel Error

Babel showing this error in /node_modules/react-scroll/lib/mixins/Helpers.js

Line 116: Unexpected token <
You may need an appropriate loader to handle this file type.
className = this.props.className
}
return <Component {...this.props} {...this.state} className={className} onClick={this.handleClick} />
}
});

Is there a reason why react-dom is used?

Line 107 of modules/mixins/Helpers.js is the only place ReactDOM is used, and from a very small test, it seems as though React.findDomNode works in place of ReactDOM.findDomNode. I am new to React, is there a reason why the react-dom package is used?

Release process suggestions

The releases in this app aren't particularly easy to find. I think this is because of 2 reasons:

  1. there aren't always dedicated release commits
  2. the tags aren't always being maintained

I'm on an app that isn't upgraded to React 15 yet, so I was trying to find older releases. It'd be awesome if you started doing those 2 things – it'd make it way easier for consumers of this lib!

Scroll to Element

Sorry for this question. Didn't see any other place to put this.
I'm trying the following but can not get a proper way to do it.

I have a large form with a lots of inputs. If the user clicks 'save' I want to be able to scroll to the first input that has the error. Tried to programmatically click the Link doesn't seem to work and I do not know the position of the input because the form is dynamic and can vary a lot from user to user.

server side rendering is failing

Isomorphic / universal React web-apps are becoming the standard
When I use react-scroll and render on the server it throws the following error:

ReferenceError: window is not defined
        at startAnimateTopScroll (...\node_modules\react-scroll\lib\mixins\animate-scroll.js:113:3)
        at Object.scrollToTop (...\node_modules\react-scroll\lib\mixins\animate-scroll.js:138:3)

I'd suggest to wrap all dependencies to window with

var canUseDOM = !!(
  typeof window !== 'undefined' &&
  window.document &&
  window.document.createElement
)
if(canUseDOM ){
     // use window dependency...
}else{
  //have an alternative that wouldn't break functionality...
}

Scrollable within a div?

Is it possible to configure scroll in order to scroll through a selected element (such as a div with overflow:scroll styling) rather than the window? I'm trying to customize the components to do so, but I might be missing an obvious functionality. Thanks

doesn't seem to be working with react 1.0.0

I'm using JSPM

import React from 'react';
import { Link as ScrollLink, Element } from 'react-scroll';

<ScrollLink to={this.props.target} smooth={true}>hi</ScrollLink>

<Element name="image"/>

when i run it says i have two version of React running
also the package requires react-dom!

Move to react 15?

Can someone update it to support react 15? currently it adds a whole react 0.14 into my bundle to support this feature.

Changelog

It'd be great to see a changelog for the different versions ✌️

ReactDOM Error

Hi, i've just encountered an error at this line :
scroller.register(this.props.name, ReactDOM.findDOMNode(this)); in Helpers.js

Uncaught TypeError: o.findDOMNode is not a function

I think it's because react-dom is not a dependency in the package.json of npm build. But even after adding the package, the error is persisting.

I have just placed a link and an element as in your exemple, and installed react-scroll and react-dom with npm. The "to" and "name" property of link and element are the same.

I'm sorry for my english errors.

Thanks

SCRIPT65535: Invalid calling object - animate-scroll.js (96,3)

Hello! I started testing an implementation of react-scroll and everything seems to work great in Safari 9, Firefox 44.0.2, and Chrome 48.0.2564.109, all on MacOS X 10.10.5. I'm using VirtualBox with the IE11 - Win11.ova that's available from Microsoft to do some MSEdge testing. The error mentioned in the subject shows up in the console of Edge when I attempt to click on a link that was set-up with react-scroll.

The way my implementation is currently set-up is that I have a StickyHeader component that contains the event listeners and Link components for react-scroll and a separate component that contains the Element react-scroll component. A basic outline would look something like this:

<Lesson> <StickyHeader /> <Element> inner content </Element> </Lesson>

I wouldn't think that having the Link and Element components in two separate files would cause a problem and so far the only error I've seen has been in IE and not the three other major browsers. To test for this, I removed the StickyHeader component and added a vanilla Link component and still received the error.

Any insight or advice you might have would be greatly appreciated.

virtualbox_ie11 - win10_19_02_2016_14_49_35

Changelog for ~1.0?

I'm currently using [email protected]; I'd like to know if I can safely upgrade to 1.0.x. Is is possible to write a quick changelog listing the breaking changes between 0.x and 1.x?

Thanks!

IE animate-scroll error

Hello,

smooth scrolling doesn't work in IE.
An error will be thrown exactly on this line
requestAnimationFrame(animateTopScroll);

can you check it please

Scroll to Element on Page Load

One thing I would like to do is be able to scroll to an Element on page load. For instance, I'm currently using react-router to change the url when a user clicks on a nav element. The user stays on the same page but the url changes. /mypage to /mypage/section1. That way the user can hand off that url to someone else and when the page loads it auto-scrolls to that section.

I think having some sort of service that tracks the registered elements would enable this scenario.

Some pseudo code.

class Page {
  componentDidMount() {
    let section = this.context.router.getParams();
    // scroll service knows about all elements on page
    myScrollService.scrollTo(section)
  }

  componentDidUnmount() {
    // let the service know to purge all its data
    myScrollService.unmount();
  }
}

offsetParent check causing problems in container scrolling

https://github.com/fisshy/react-scroll/blob/master/modules/mixins/scroller.js#L65

Container with ID ' + containerId + ' is not a positioned element

So I'm running into an issue while trying to scroll a container (via containerId prop) to a specified Element. It's hitting the above linked error even thought the container specified is in fact a positioned element.

Here's what's happening:

I have a containerElement that I want to scroll which is a positioned element. I then have an Element nested fairly deep inside this container that I want to scroll to. When I try to scroll I hit the aforementioned error. This is happening because there is another positioned DOM element between the containerElement and the Element I am trying to scroll to. This causes the offsetParent of the target Element to be set to set to the intermediate element rather than the desired containerElement.

I understand why offsetParent is used here, but it prevents the use of other positioned elements between the desired container and the target element. If this is a limitation that can't be avoided then the error handling should probably be updated, because the error is misleading and incorrect.

@fisshy @poacher2k

webpack -wd in production

Hey

Any idea on why i am getting this in production env:

WARNING in scripts.min.js from UglifyJs
Condition always true [.//scrollreveal/dist/scrollreveal.js:3,0]
Dropping unreachable code [./
/scrollreveal/dist/scrollreveal.js:5,3]

thanks,
Rares

API to force a scroll?

Is there a way to force a scroll to top without clicking on ScrollToElement / Link? For example, if I'm on a page with params and navigating between them, currently it keeps me at the page position rather than scrolling me back to the top of the page. I'd like to manually do this if it's possible.

Divs with dynamic heights

Awesome library, using it on my personal portfolio website, www.kuiros.io. I have divs/sections that are dynamic in height so that they change height when I resize the window. This messes up the anchors where the links scroll to. Is there any way to refresh the anchor positions on a window resize? Thanks a lot.

Code duplication

Duplicated code was committed in 951f21b. You can see it here. This is a bug itself, but the worst thing is that it causes Safari 8 to throw js error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.