Skip to content
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
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ declare module "react-native-root-toast"{
onHidden?: Function,
onShow?: Function,
onShown?: Function,
onPress?: Function
onPress?: Function,
mask?: boolean,
}

export interface ToastProps extends ToastOptions,ReactNative.ViewProperties{
Expand Down
18 changes: 11 additions & 7 deletions lib/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class ToastContainer extends Component {
onHide: PropTypes.func,
onHidden: PropTypes.func,
onShow: PropTypes.func,
onShown: PropTypes.func
onShown: PropTypes.func,
mask: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -93,7 +94,8 @@ class ToastContainer extends Component {
opacity: 0.8,
delay: 0,
hideOnPress: true,
keyboardAvoiding: true
keyboardAvoiding: true,
mask: false,
};

constructor() {
Expand All @@ -104,7 +106,8 @@ class ToastContainer extends Component {
opacity: new Animated.Value(0),
windowWidth: window.width,
windowHeight: window.height,
keyboardScreenY: window.height
keyboardScreenY: window.height,
mask: this.props.mask,
};
}

Expand Down Expand Up @@ -194,11 +197,11 @@ class ToastContainer extends Component {
pointerEvents: 'none'
});
}

if (this.props.onHide) {
this.props.onHide(this.props.siblingManager);
}

Animated.timing(this.state.opacity, {
toValue: 0,
duration: this.props.animation ? TOAST_ANIMATION_DURATION : 0,
Expand All @@ -207,6 +210,7 @@ class ToastContainer extends Component {
}).start(({finished}) => {
if (finished) {
this._animating = false;
this.setState({mask: false});
this.props.onHidden && this.props.onHidden(this.props.siblingManager);
}
});
Expand All @@ -215,7 +219,7 @@ class ToastContainer extends Component {

render() {
let {props} = this;
const { windowWidth } = this.state;
const { windowWidth, mask } = this.state;
let offset = props.position;

const { windowHeight, keyboardScreenY } = this.state;
Expand All @@ -232,7 +236,7 @@ class ToastContainer extends Component {
styles.defaultStyle,
position
]}
pointerEvents="box-none"
pointerEvents= {mask ? 'box-only' : 'box-none'}
>
<TouchableWithoutFeedback
onPress={() => {
Expand Down