Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.DS_Store
node_modules/
es
node_modules
umd
/*.js
!rollup.config.js
*.sublime-project
*.sublime-workspace
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
src/
tools
*.sublime-project
*.sublime-workspace
175 changes: 0 additions & 175 deletions index.js

This file was deleted.

73 changes: 55 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
{
"name": "react-scroll-trigger",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"description": "React component tied to scroll events with callbacks for enter, exit and progress while scrolling through the viewport.",
"keywords": [
"react",
"react-component",
"scroll",
"trigger"
"repository": "ryanhefner/react-scroll-trigger",
"author": "Ryan Hefner <hi@ryanhefner.com> (https://www.ryanhefner.com)",
"files": [
"index.js",
"es",
"umd"
],
"directories": {
"lib": "/src"
},
"main": "index.js",
"module": "es/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"compile": "babel -d ./ src/",
"prepublish": "npm run compile",
"clean": "rm -f index.js && rm -rf es && rm -rf umd",
"prebuild": "npm run clean",
"build": "node ./tools/build.js",
"watch": "babel ./src -d . --ignore __tests__ --watch",
"prepare": "npm run build",
"prepublishOnly": "node ./tools/build.js",
"push-release": "git push origin master && git push --tags",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "git@github.com:ryanhefner/react-scroll-trigger.git",
"author": "Ryan Hefner <hi@ryanhefner.com> (https://www.ryanhefner.com)",
"license": "MIT",
"peerDependencies": {
"react": ">=15"
},
"dependencies": {
"clean-react-props": "^0.1.0",
"lodash.throttle": "^4.1.1",
"prop-types": "^15.5.10",
"react-dom": "^15.6.1"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.6",
"babel-preset-latest": "^6.24.1",
"babel-preset-react": "^6.24.1"
},
"dependencies": {
"lodash": "^4.17.4",
"prop-types": "^15.5.10",
"babel-preset-react": "^6.24.1",
"gzip-size": "^3.0.0",
"jest": "^20.0.4",
"pretty-bytes": "^4.0.2",
"react": "^15.6.1",
"react-dom": "^15.6.1"
}
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"rollup-watch": "^4.3.1"
},
"browserify": {
"transform": [
"loose-envify"
]
},
"keywords": [
"react",
"react-component",
"scroll",
"trigger"
]
}
37 changes: 37 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import pkg from './package.json';

const config = {
entry: 'src/index.js',
format: 'umd',
moduleName: 'react-scroll-trigger',
plugins: [
babel({
exclude: 'node_modules/**',
}),
resolve(),
commonjs({
include: /node_modules/,
}),
json(),
],
external: [
'react',
],
globals: {
'react': 'React',
},
dest: './index.js',
banner: `/*! ${pkg.name} v${pkg.version} | (c) ${new Date().getFullYear()} Ryan Hefner | ${pkg.license} License | https://github.com/${pkg.repository} !*/`,
footer: '/* follow me on Twitter! @ryanhefner */',
};

if (process.env.NODE_ENV === 'production') {
config.plugins.push(uglify());
}

export default config;
3 changes: 3 additions & 0 deletions src/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "../tools/babel-preset.js" ]
}
13 changes: 3 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import omit from 'lodash/omit';
import throttle from 'lodash/throttle';
import throttle from 'lodash.throttle';
import cleanProps from 'clean-react-props';

class ScrollTrigger extends Component {

Expand Down Expand Up @@ -123,16 +123,9 @@ class ScrollTrigger extends Component {
children,
} = this.props;

const props = omit(this.props, [
'onEnter',
'onExit',
'onProgress',
'triggerOnLoad',
]);

return (
<div
{...props}
{...cleanProps(this.props)}
ref={(element) => {
this.element = element;
}}
Expand Down
28 changes: 28 additions & 0 deletions tools/babel-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const BABEL_ENV = process.env.BABEL_ENV;
const building = BABEL_ENV != undefined && BABEL_ENV !== 'cjs';

const plugins = [];

if (BABEL_ENV === 'umd') {
plugins.push('external-helpers');
}

if (process.env.NODE_ENV === 'production') {
plugins.push(
'dev-expression',
'transform-react-remove-prop-types'
);
}

module.exports = {
presets: [
['latest', {
'es2015': {
'loose': true,
'modules': building ? false : 'commonjs'
}
}],
'react'
],
plugins: plugins
};
Loading