Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaLibrary - set minimun limito to sticky the header panel #12117

Merged
merged 2 commits into from
Mar 14, 2017
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
20 changes: 18 additions & 2 deletions client/components/sticky-panel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@ var viewport = require( 'lib/viewport' );
module.exports = React.createClass( {
displayName: 'StickyPanel',

propTypes: {
minLimit: React.PropTypes.oneOfType( [
React.PropTypes.bool,
React.PropTypes.number,
] ),
},

getDefaultProps: function() {
return {
minLimit: false,
};
},

getInitialState: function() {
return {
isSticky: false,
spacerHeight: 0,
blockWidth: 0
blockWidth: 0,
};
},

Expand Down Expand Up @@ -53,7 +66,10 @@ module.exports = React.createClass( {
updateIsSticky: function() {
var isSticky = window.pageYOffset > this.threshold;

if ( viewport.isMobile() ) {
if (
this.props.minLimit !== false && this.props.minLimit >= window.innerWidth ||
viewport.isMobile()
) {
return this.setState( { isSticky: false } );
}

Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/media-library/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default React.createClass( {

if ( this.props.sticky ) {
return (
<StickyPanel>
<StickyPanel minLimit ={ 660 }>
{ card }
</StickyPanel>
);
Expand Down