Code Monkey home page Code Monkey logo

react-intersection-visible's Introduction

react-intersection-visible

HOC-wrapper Component that helps you track when an element enters in the viewport. It uses the new IntersectionObserver API with polyfill fallback

Demo

Build Status Greenkeeper badge

How to use

  1. Import IntersectionVisible hoc component
  2. Wrap your main component with the IntersectionVisible
  3. Provide the options and callbacks you want

Example

import React, { Component }   from 'react';
import ReactDOM               from 'react-dom';
import IntersectionVisible    from 'react-intersection-visible';

class YourComponent extends Component
{

    onHide( entries )
    {
        // do something
    }

    onShow( entries )
    {
        // do something
    }

    onIntersect( entries )
    {
        // do something
    }

    render(){
        return (<IntersectionVisible onIntersect={ e => this.onIntersect( e ) }
                                     onHide={ e => this.onHide( e ) }
                                     onShow={ e => this.onShow( e ) }>
                    <div>
                        blah blah blah  blah blah blah  blah blah blah  blah blah
                          blah blah blah  blah blah blah  blah blah blah
                    </div>
                </IntersectionVisible>);
    }
}

Options:

Name Description
onIntersect Function that is called when the visibility status of the element change
onHide Function that is called when the element becomes invisible
onShow Function that is called when the element becomes visible
options Object, with the extras options supported by the IntersectionObserver API (root, rootMargin, threshold)

More about the options here

Contribute

Any pull-request is more than welcome 💥 😄

License

MIT

react-intersection-visible's People

Contributors

avraammavridis avatar axelhzf avatar greenkeeper[bot] avatar modkaffes avatar tomfordweb avatar xaiki 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

Watchers

 avatar  avatar  avatar

react-intersection-visible's Issues

An in-range update of react is breaking the build 🚨

There have been updates to the react monorepo:

    • The devDependency react was updated from 16.10.1 to 16.10.2.
  • The devDependency react-dom was updated from 16.10.1 to 16.10.2.
  • The devDependency react-test-renderer was updated from 16.10.1 to 16.10.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for 16.10.2 (October 3, 2019)

React DOM

  • Fix regression in react-native-web by restoring order of arguments in event plugin extractors (@necolas in #16978)

Artifacts

• react: https://unpkg.com/[email protected]/umd/
• react-art: https://unpkg.com/[email protected]/umd/
• react-dom: https://unpkg.com/[email protected]/umd/
• react-is: https://unpkg.com/[email protected]/umd/
• react-test-renderer: https://unpkg.com/[email protected]/umd/
• scheduler: https://unpkg.com/[email protected]/umd/

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Failed to execute 'observe'

I’m getting the following error:

Uncaught (in promise) TypeError: Failed to execute 'observe' on 'IntersectionObserver': parameter 1 is not of type 'Element'.
    at Visible.startObserving (index.js?767f:81)
    at Visible.componentDidMount (index.js?767f:120)
    at eval (ReactCompositeComponent.js?063f:262)
    at measureLifeCyclePerf (ReactCompositeComponent.js?063f:73)
    at eval (ReactCompositeComponent.js?063f:261)
    at CallbackQueue.notifyAll (CallbackQueue.js?7abf:74)
    at ReactReconcileTransaction.close (ReactReconcileTransaction.js?2d36:78)
    at ReactReconcileTransaction.closeAll (Transaction.js?91bc:207)
    at ReactReconcileTransaction.perform (Transaction.js?91bc:154)
    at ReactUpdatesFlushTransaction.perform (Transaction.js?91bc:141)

My code thus far:

/*
 * HomePage
 */

import React from 'react';
import styles from './styles.css';
import IntersectionVisible from 'react-intersection-visible';

import Column from './Column';
import { columns } from './columns';

export class HomePage extends React.Component {
	onIntersect(entries) {
		console.log('Hidden or Visible');
	}

	onHide(entries) {
		console.log('Hidden');
	}

	onShow(entries) {
		console.log('Visible');
	}

	render() {
		const { isReady } = this.state;

		return (
			<div className={ styles.base }>
				<section>
					{ columns.map((column, index) => {
						const sections = column.sections;
						const featured = column.featured;
						const columnData = {
							column,
							isReady,
							sections,
							featured,
							index
						};

						return (
							<IntersectionVisible
								key={ `Section_${index}` }
								onIntersect={ this.onIntersect }
								onHide={ this.onHide }
								onShow={ this.onShow }
							>
								<Column { ...columnData } key={ `Column_${index}` } logLoadedSVG={ this.logLoadedSVG } />
							</IntersectionVisible>
						);
					})}
				</section>
			</div>
		);
	}
}

export default HomePage;

Any ideas?

An in-range update of enzyme is breaking the build 🚨

There have been updates to the enzyme monorepo:

    • The devDependency enzyme was updated from 3.9.0 to 3.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the enzyme group definition.

enzyme is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-react is breaking the build 🚨

The devDependency eslint-plugin-react was updated from 7.16.0 to 7.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v7.17.0

Added

Fixed

Changed

Commits

The new version differs by 26 commits.

  • 027ebd9 Update CHANGELOG and bump version
  • 89911de [Deps] update jsx-ast-utils, object.fromentries, resolve
  • cfef664 [Dev Deps] update @types/eslint, @types/estree, @types/node, coveralls, typescript
  • d3b5d71 [New] jsx-no-target-blank: add allowReferrer option
  • 83ac4c0 [eslint] fix func-names and change object-shorthand to 'always'
  • 225b433 [Docs] jsx-first-prop-new-line: Fix documentation formatting
  • 62df1dd [Docs] prop-types: Update 'skipUndeclared' in rule options
  • 87d4cab [Docs] jsx-first-prop-new-line: fix wrong rule name
  • 55b605f [Fix] sort-prop-types, jsx-sort-default-props: disable broken autofix
  • 71c7d01 [Tests] temporarily pin eslint 6 tests to v6.6
  • 8093565 [New] jsx-handler-names: add checkLocalVariables option
  • 5be539b [Fix] no-typos: improve report location
  • d9d2193 [eslint] enable eslint-plugin-eslint-plugin
  • 39e4396 [Docs] jsx-props-no-multi-spaces: suggest using core rule instead
  • 9e4ad21 [Docs] jsx-first-prop-new-line: add rule options

There are 26 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.17.2 to 2.17.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 25 commits.

  • cf5573b Bump to v2.17.3
  • caae65c [Tests] eslint 2 does not have linter.version
  • 557a3e2 [Deps] update resolve
  • 17beb33 Merge pull request #1356 from christophercurrie/typescript-declare
  • c8ac7ff [Docs] Document env option for eslint-import-resolver-webpack
  • c09c0ce Issue #1258 (docs)
  • 753c9db [refactor] fix eslint 6 compat by fixing imports
  • b52bf3e PR feedback
  • 7aa13d1 PR feedback
  • f66e064 Remove log messages
  • d1e4455 Verbose variable names
  • 67b1e95 Support older typescript parsers
  • 288cedf Make groups non-capturing.
  • aa290bb Improve support for Typescript declare structures
  • 1edbbd0 [Fix] no-common-js: Also throw an error when assigning

There are 25 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of enzyme is breaking the build 🚨

There have been updates to the enzyme monorepo:

    • The devDependency enzyme was updated from 3.9.0 to 3.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the enzyme group definition.

enzyme is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Error in readme

You have a slight error in your docs. There is an extra greater than sign after the onHide prop.

<IntersectionVisible onIntersect={ e => this.onIntersect( e ) }
                                    onHide={ e => this.onHide( e ) }>
                                     onShow={ e => this.onShow( e ) }> 

Thanks for sharing this package, I have found it very useful for my current project!

An in-range update of react is breaking the build 🚨

There have been updates to the react monorepo:

    • The devDependency react was updated from 16.6.1 to 16.6.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 5.15.3 to 5.16.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v5.16.0
  • dfef227 Build: gensite passes rulesMeta to formatter rendering (#11567) (Kevin Partington)
  • c06d38c Fix: Allow HTML formatter to handle no meta data (#11566) (Ilya Volodin)
  • 87a5c03 Docs: func-style: clarify when allowArrowFunctions is used (#11548) (Oliver Joseph Ash)
  • bc3e427 Update: pass rule meta to formatters RFC 10 (#11551) (Chris Meyer)
  • b452f27 Chore: Update README to pull in reviewer data (#11506) (Nicholas C. Zakas)
  • afe3d25 Upgrade: Bump js-yaml dependency to fix Denial of Service vulnerability (#11550) (Vernon de Goede)
  • 4fe7eb7 Chore: use nyc instead of istanbul (#11532) (Toru Nagashima)
  • f16af43 Chore: fix formatters/table test (#11534) (Toru Nagashima)
  • 78358a8 Docs: fix duplicate punctuation in CLI docs (#11528) (Teddy Katz)
Commits

The new version differs by 11 commits.

  • ded2f94 5.16.0
  • ea36e13 Build: changelog update for 5.16.0
  • dfef227 Build: gensite passes rulesMeta to formatter rendering (#11567)
  • c06d38c Fix: Allow HTML formatter to handle no meta data (#11566)
  • 87a5c03 Docs: func-style: clarify when allowArrowFunctions is used (#11548)
  • bc3e427 Update: pass rule meta to formatters RFC 10 (#11551)
  • b452f27 Chore: Update README to pull in reviewer data (#11506)
  • afe3d25 Upgrade: Bump js-yaml dependency to fix Denial of Service vulnerability (#11550)
  • 4fe7eb7 Chore: use nyc instead of istanbul (#11532)
  • f16af43 Chore: fix formatters/table test (#11534)
  • 78358a8 Docs: fix duplicate punctuation in CLI docs (#11528)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Invalid rootMargin type expected

I am using the rootMargin option as such:

 <IntersectionVisible onHide={() => this.onHide()} onShow={() => this.onShow()} options={{ rootMargin: '-100px 0px 0px 0px' }}>

But I am receiving an error in the browser console:

Warning: Failed prop type: Invalid prop `options.rootMargin` of type `string` supplied to `IntersectionVisible`, expected `number`.

Unless I'm misreading, it seems that string is the expected type by the IntersectionObserver API. For kicks, I used a number and received the following error:

Uncaught DOMException: Failed to construct 'IntersectionObserver': rootMargin must be specified in pixels or percent.

Removing the polyfill breaks apps on iOS safari

Manual import 'intersection-observer'; is needed now. However, the readme still states that the polyfill fallback is in place.

Removing the polyfill is a breaking change. I suggest re-adding it for 2.10.1 and removing it in 3.0.0

This way the breaking change is not installed automatically.

An in-range update of enzyme is breaking the build 🚨

There have been updates to the enzyme monorepo:

    • The devDependency enzyme was updated from 3.8.0 to 3.9.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the enzyme group definition.

enzyme is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Broken SSR

Thanks for this component at first!
import 'intersection-observer';
breaks down SSR due it uses window object without checking for available inside of it.
Please, can you remove this import and warn this in Readme instead?
Checked at Gatsby 2 at build command.
Thanks!

An in-range update of babel-loader is breaking the build 🚨

The devDependency babel-loader was updated from 8.0.2 to 8.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

babel-loader is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v8.0.3

Features

  • #687 - Add customize option

Bugs

  • #685 - Also pass the caller option to loadPartialConfig

Docs

  • #681 - Update the README links to use the new options docs
  • #683 - Add .mjs to the examples

Internal

Some dev dependency updates and CI tweaks.

Commits

The new version differs by 12 commits.

  • 800181b 8.0.3
  • 7d8500c Also pass the caller option to loadPartialConfig (#685)
  • a507914 Expose the full loader options to all overrides hooks.
  • ac0c869 Tweak the customize implementation to be a bit more strict.
  • 9b70a02 Add overrides option
  • c8d7a72 Add .mjs to the examples (#683)
  • 4619993 bable options link update (#681)
  • 8f240b4 Use node 10 on appveyor
  • 7e4189e Change appveyor to use babel account
  • eeaee46 Update devDeps to use most recent versions, and fix tests.
  • 3e5fb5e chore(package): update lockfile
  • 2b8e479 chore(package): update eslint-config-babel to version 8.0.0

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of codecov is breaking the build 🚨

The devDependency codecov was updated from 3.6.2 to 3.6.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

codecov is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v3.6.3

AWS Codebuild fixes + package updates

Commits

The new version differs by 10 commits.

  • 7856231 v3.6.3
  • 96e6d96 Merge pull request #166 from codecov/chore/updates
  • c8ea169 update deps
  • 7c4cdc4 Merge pull request #149 from aiell0/master
  • 62389fa Merge pull request #162 from codecov/dependabot/npm_and_yarn/handlebars-4.5.3
  • 73ae008 Add dependabot config
  • ccf3862 Update README.md
  • 467a495 Bump handlebars from 4.1.2 to 4.5.3
  • 8acbe96 Retest
  • acd92f4 Test when codebuild isn't triggered by webhooks.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.