Skip to content

Commit a6ed386

Browse files
committed
Adds activeClass property
1 parent 7bb7c1a commit a6ed386

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ var Sticky = require('react-stickynode');
5151
- `enabled {Boolean}` - The switch to enable or disable Sticky (true by default).
5252
- `top {Number/String}` - The offset from the top of window where the top of the element will be when sticky state is triggered (0 by default). If it is a selector to a target (via `querySelector()`), the offset will be the height of the target.
5353
- `bottomBoundary {Number/String}` - The offset from the top of document which release state will be triggered when the bottom of the element reaches at. If it is a selector to a target (via `querySelector()`), the offset will be the bottom of the target.
54-
- `enableTransforms {Boolean}` - Enable the use of CSS3 transforms (true by default)
54+
- `enableTransforms {Boolean}` - Enable the use of CSS3 transforms (true by default).
55+
- `activeClass {String}` - Class name to be applied to the element when the sticky state is active (`active` by default).
5556

5657
## Install & Development
5758

src/Sticky.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class Sticky extends Component {
312312
}
313313

314314
return (
315-
<div ref='outer' className={classNames('sticky-outer-wrapper', self.props.className)} style={outerStyle}>
315+
<div ref='outer' className={classNames('sticky-outer-wrapper', self.props.className, {[self.props.activeClass]: self.state.status === STATUS_FIXED})} style={outerStyle}>
316316
<div ref='inner' className='sticky-inner-wrapper' style={innerStyle}>
317317
{self.props.children}
318318
</div>
@@ -325,7 +325,8 @@ Sticky.defaultProps = {
325325
enabled: true,
326326
top: 0,
327327
bottomBoundary: 0,
328-
enableTransforms: true
328+
enableTransforms: true,
329+
activeClass: 'active'
329330
};
330331

331332
/**
@@ -346,7 +347,8 @@ Sticky.propTypes = {
346347
PropTypes.string,
347348
PropTypes.number
348349
]),
349-
enableTransforms: PropTypes.bool
350+
enableTransforms: PropTypes.bool,
351+
activeClass: PropTypes.string
350352
};
351353

352354
module.exports = Sticky;

0 commit comments

Comments
 (0)