Skip to content

Commit

Permalink
feat: add viewStyle prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Apr 30, 2019
1 parent d4bc6ea commit 76bf416
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ Any extra class names to add to the inner "viewport" element.

Extra inline styles to add to the inner "viewport" element.

##### `viewStyle: Object`

Extra inline styles to add to the view wrapper elements.

##### `rootRef: (node: ?HTMLDivElement) => any`

The `ref` to pass to the root `<div>` element rendered by `ViewSlider`.
Expand Down
2 changes: 1 addition & 1 deletion demo/bundle.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type Props = {
style: Object,
viewportClassName?: string,
viewportStyle: Object,
viewStyle?: ?Object,
rootRef?: (node: ?React.ElementRef<'div'>) => mixed,
viewportRef?: (node: ?React.ElementRef<'div'>) => mixed,
rtl: boolean,
Expand All @@ -60,7 +61,7 @@ const fillStyle = {
bottom: 0,
}

const viewStyle = {
const baseViewStyle = {
display: 'inline-block',
verticalAlign: 'top',
whiteSpace: 'normal',
Expand Down Expand Up @@ -172,10 +173,17 @@ export default class ViewSlider extends React.Component<Props, State> {
}

renderView = (index: number): React.Node => {
const { fillParent, prefixer, keepViewsMounted, spacing, rtl } = this.props
const {
fillParent,
prefixer,
keepViewsMounted,
spacing,
rtl,
viewStyle,
} = this.props
const { activeView, transitioning } = this.state

const style: Object = { display: 'flex', ...viewStyle }
const style: Object = { ...baseViewStyle, ...viewStyle }
if (fillParent) {
Object.assign(style, fillStyle)
style.overflow = 'auto'
Expand Down
1 change: 1 addition & 0 deletions src/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Props = {
style?: Object,
viewportClassName?: string,
viewportStyle?: Object,
viewStyle?: ?Object,
rootRef?: (node: ?React.ElementRef<'div'>) => mixed,
viewportRef?: (node: ?React.ElementRef<'div'>) => mixed,
rtl?: ?boolean,
Expand Down

0 comments on commit 76bf416

Please sign in to comment.