Git Product home page Git Product logo

Comments (8)

keidrun avatar keidrun commented on May 6, 2024 1

Recently I migrated my bootstrap4 project to reactstrap but unfortunately it didn't support a scrollspy... So, I had no choice but created and published a small library to implement a scrollspy for reactstrap. It provides just a minimum feature but check out reactstrap-scrollspy if you're interested in.

from reactstrap.

zeroasterisk avatar zeroasterisk commented on May 6, 2024
  1. possible: https://github.com/fisshy/react-scroll
  2. possible: https://github.com/makotot/react-scrollspy

from reactstrap.

gesposito avatar gesposito commented on May 6, 2024

Hey, while investigating on how to implement Scrollspy I focused onto
https://github.com/camwiegert/in-view
and I found out that there already are a couple of implementations, i.e.:

the API for Scrollspy would be something like react-in-view does:

<Scrollspy
  onEnter={this.handleEnter}
  onLeave={this.handleLeave}
  threshold={{ x: 0, y: 0 }}
  offset={{ top: 0, right: 0, bottom: 0, left: 0 }}
>
  <div>Spied component</div>
</Scrollspy>

where callbacks would be used to update state (and set active Nav elements).

Would this be a suitable solution for you?

from reactstrap.

gesposito avatar gesposito commented on May 6, 2024

As a second option there are a couple of HoC, i.e.:

react-in-viewport relies on Intersection Observer API
the API would then be something like:

<Scrollspy
  onEnter={this.handleEnter}
  onLeave={this.handleLeave}
  options={{
    margin: "0 0 0 0",
    threshold: 10 // Percentage
  }}
  config={{ disconnectOnLeave: boolean }}
>
  <div>Spied component</div>
</Scrollspy>;

from reactstrap.

eeriee avatar eeriee commented on May 6, 2024

I saw this feature was removed from To Do. Is reactstrap going to support Scrollspy?

from reactstrap.

TheSharpieOne avatar TheSharpieOne commented on May 6, 2024

I know this is kinda a cop-out, but since scrollspy doesn't really do much other than add a the active class based on scrolling and there are libs out there which currently do that and do that very well, we haven't implemented it and instead just suggest the use of things like react-scrollspy.

You're probably like "there are tons of libraries which do things like dropdowns (react-select) and modals (react-modal) and reactstrap has those built-in", but they do not look like or work like bootstrap out-of-the-box. react-scrollspy does (given that you set currentClassName="active").

Maybe we could has react-scrollspy as a dep and expose it with currentClassName="active" as the default so that reactstrap includes the feature without really having to maintain it. Honestly though, I don't think that many people use it.

from reactstrap.

TheSharpieOne avatar TheSharpieOne commented on May 6, 2024

@keidrun awesome! If you'd like, submit a PR to add it to the In the wild section of the docs.

from reactstrap.

keidrun avatar keidrun commented on May 6, 2024

@TheSharpieOne Sure. I'd love to.

from reactstrap.

Related Issues (20)

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.