Skip to content

Commit

Permalink
feat: expose gapMode
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Nov 13, 2018
1 parent 992d1e7 commit 0298cc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Now you could __focus on__ a single task.
- `[onDeactivation]` - on deactivation callback
- `[onClickOutside]` - on click outside of "focus" area. (actually on any event "outside")
- `[onEscapeKey]` - on Esc key pressed (and not defaultPrevented)
- `[gapMode]` - the way removed ScrollBar would be _compensated_ - margin(default), or padding. See [scroll-locky documentation](https://github.com/theKashey/react-scroll-locky#gap-modes) to find the one you need.

## Additional API
### Exposed from React-Focus-Lock
Expand Down
7 changes: 6 additions & 1 deletion src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import {ScrollLocky} from 'react-scroll-locky';
import ReactFocusLock from 'react-focus-lock'
import {hideOthers} from 'aria-hidden';

type GapMode = 'padding' | 'margin';

export interface ReactFocusOnProps {
enabled?: boolean;
autoFocus?: boolean;
onActivation?: (node: HTMLElement) => void;
onDeactivation?: () => void;

gapMode?: GapMode;

onClickOutside?: () => void;
onEscapeKey?: (event: Event) => void;
}
Expand Down Expand Up @@ -46,11 +50,12 @@ export class ReactFocusOn extends Component<ReactFocusOnProps> {
};

render() {
const {children, autoFocus, onClickOutside, enabled = true} = this.props;
const {children, autoFocus, onClickOutside, gapMode, enabled = true} = this.props;
return (
<ScrollLocky
enabled={enabled}
onEscape={onClickOutside}
gapMode={gapMode}
>
<ReactFocusLock
autoFocus={autoFocus}
Expand Down

0 comments on commit 0298cc8

Please sign in to comment.