Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.

Add background-position-y as an option for the background image #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion src/LazyHero.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ class LazyHero extends Component {
imageHeight={backgroundDimensions && backgroundDimensions.height}
imageSrc={this.props.imageSrc}
imageWidth={backgroundDimensions && backgroundDimensions.width}
style={{ backgroundPositionY }}
style={{
backgroundPositionY: (
this.props.backgroundPositionY
? this.props.backgroundPositionY
: backgroundPositionY
),
}}
transitionDuration={this.props.transitionDuration}
transitionTimingFunction={this.props.transitionTimingFunction}
/>
Expand All @@ -176,6 +182,7 @@ class LazyHero extends Component {
}

LazyHero.defaultProps = {
backgroundPositionY: undefined,
children: undefined,
className: undefined,
color: '#fff',
Expand All @@ -191,6 +198,7 @@ LazyHero.defaultProps = {
};

LazyHero.propTypes = {
backgroundPositionY: PropTypes.string,
children: PropTypes.node,
className: PropTypes.string,
color: PropTypes.string,
Expand Down
5 changes: 5 additions & 0 deletions website/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function App(props) {
return (
<div className="App">
<LazyHero
backgroundPositionY={props.knobs.backgroundPositionY.current}
className={props.knobs.className.current}
color={props.knobs.color.current}
imageSrc={props.knobs.imageSrc.current}
Expand Down Expand Up @@ -54,6 +55,10 @@ const enhance = compose(
pure,
withState('id', 'setId', 0),
withState('knobs', 'setKnobs', {
backgroundPositionY: {
description: 'backgroundPositionY property on the image. Will override parallax effect.',
type: 'string',
},
children: {
current: '<Logo />',
description: 'Child components',
Expand Down