fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 437 forks source link

Custom spy element #334

Closed Noitidart closed 6 years ago

Noitidart commented 6 years ago

Similar to how we can create a custom Link, is it possible to create an element that is a custom spy element? I just want a certain element to have a certain class when a containerId is within view.

CC: @1yzo

fisshy commented 6 years ago

Yes it should be possible.

...
let ScrollElement = Scroll.ScrollElement;

var Element = React.createClass({
  render: function () {
    return (
      <div {...this.props}>
        {this.props.children}
      </div>
    );
  }
});

module.exports = ScrollElement(Element);
Noitidart commented 6 years ago

Thank you I will try this out! Will close for now