Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-stickynode

Package Overview
Dependencies
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-stickynode - npm Package Compare versions

Comparing version 1.0.16 to 1.0.18

18

dist/Sticky.js

@@ -39,2 +39,3 @@ /**

var STATUS_FIXED = 2; // The sticky status, locating fixed to the top or the bottom of screen.
var TRANSFORM_PROP = 'transform';

@@ -323,2 +324,9 @@

}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps, prevState) {
if (prevState.status !== this.state.status && this.props.onStateChange) {
this.props.onStateChange({ status: this.state.status });
}
}
}, {
key: 'componentWillUnmount',

@@ -398,3 +406,4 @@ value: function componentWillUnmount() {

enableTransforms: true,
activeClass: 'active'
activeClass: 'active',
onStateChange: null
};

@@ -415,5 +424,10 @@

enableTransforms: _react.PropTypes.bool,
activeClass: _react.PropTypes.string
activeClass: _react.PropTypes.string,
onStateChange: _react.PropTypes.func
};
Sticky.STATUS_ORIGINAL = STATUS_ORIGINAL;
Sticky.STATUS_RELEASED = STATUS_RELEASED;
Sticky.STATUS_FIXED = STATUS_FIXED;
module.exports = Sticky;

9

package.json
{
"name": "react-stickynode",
"version": "1.0.16",
"version": "1.0.18",
"description": "A performant and comprehensive React sticky",

@@ -40,5 +40,6 @@ "main": "index.js",

"es5-shim": "^4.0.0",
"eslint": "^2.4.0",
"eslint-plugin-react": "^4.2.3",
"eslint": "^2.4.0",
"expect.js": "^0.3.1",
"grunt": "^0.4.5",
"grunt-atomizer": "^3.0.0",

@@ -54,3 +55,2 @@ "grunt-babel": "^5.0.0",

"grunt-webpack": "^1.0.8",
"grunt": "^0.4.5",
"istanbul": "^0.4.0",

@@ -64,4 +64,5 @@ "jsdom": "^8.0.0",

"pre-commit": "^1.0.0",
"react": "^0.14.2",
"react-dom": "^0.14.2",
"react": "^0.14.2",
"sinon": "^1.17.3",
"xunit-file": "~0.0.9"

@@ -68,0 +69,0 @@ },

@@ -56,3 +56,27 @@ # react-stickynode

- `activeClass {String}` - Class name to be applied to the element when the sticky state is active (`active` by default).
- `onStateChange {Function}` - Callback for when the sticky state changes. See below.
### Handling State Change
You can be notified when the state of the sticky component changes by passing a callback to the `onStateChange` prop. The callback will receive an object in the format `{status: CURRENT_STATUS}`, with `CURRENT_STATUS` being an integer representing the status:
- 0 (STATUS_ORIGINAL) - The default status, located at the original position.
- 1 (STATUS_RELEASED) - The released status, located at somewhere on document, but not default one.
- 2 (STATUS_FIXED) - The sticky status, located fixed to the top or the bottom of screen.
You can access the statuses as static constants to use for comparison.
```js
var Sticky = require('react-stickynode');
const handleStateChange = (status) => {
if (status.status === Sticky.STATUS_FIXED) {
console.log('the component is sticky');
}
}
<Sticky onStateChange={handleStateChange}>
<YourComponent/>
</Sticky>
```
## Install & Development

@@ -59,0 +83,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc