Code Monkey home page Code Monkey logo

Comments (2)

hawkins avatar hawkins commented on September 23, 2024 1

One idea of an example that might be particularly useful is how someone might use this library to force an element to be visible.

For instance, render a component that is found to be not visible after scrolling. Then, if the component is found to be not visible, find how far out of bounds it is and apply CSS to shift the element back into the viewport. Effectively, this is similar to a "Sticky" component, but this imperative perspective added by react-visibility-sensor might make it easier for users to adapt the process to fit their own use cases (i.e., navigation bar dropdowns moving inward if part of their content would have gone off the scren) where a typical Sticky component would not


Additionally, for making examples, I've found lately that plain React development build pages that house the component and simply spit out property values with just span tags or similar are plenty for me. This is because I can use React Dev Tools on these pages and manipulate property values myself, just as I would if I were developing an app that used the component.

Otherwise, I'd suggest CodeSandbox because it's a codepen-esque site built specifically for react components. The npm integration might make demos more valuable since users could involve other third-party components right there in the demo to see how well they play together.

from react-visibility-sensor.

joshwnj avatar joshwnj commented on September 23, 2024

Nice ideas. Agree about CodeSandbox. I haven't tried it yet but seems like it would be a great option for this.

Some other examples that come to mind would be thinking of some common use-cases, like:

  • triggering an animation when an element becomes visible
  • lazy-loading an image when it's <=200px outside the viewport

from react-visibility-sensor.

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.