Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: set correct pointer events when active prop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
osdnk authored and satya164 committed Aug 22, 2019
1 parent 1a8281d commit 1bbd6ac
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/stack/src/views/Stack/PointerEventsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const { block, greaterThan, cond, set, call, onChange } = Animated;
* whenever position changes.
*/
export default class PointerEventsView extends React.Component<Props> {
componentDidUpdate(prevProps: Props) {
if (this.props.active !== prevProps.active) {
this.pointerEventsEnabled.setValue(this.props.active ? TRUE : FALSE);
this.setPointerEventsEnabled(this.props.active);
}
}

private pointerEventsEnabled = new Animated.Value<Binary>(
this.props.active ? TRUE : FALSE
);
Expand All @@ -40,13 +47,17 @@ export default class PointerEventsView extends React.Component<Props> {
onChange(
this.pointerEventsEnabled,
call([this.pointerEventsEnabled], ([value]) => {
const pointerEvents = this.props.active && value ? 'box-none' : 'none';

this.root && this.root.setNativeProps({ pointerEvents });
this.setPointerEventsEnabled(Boolean(this.props.active && value));
})
),
]);

private setPointerEventsEnabled = (enabled: boolean) => {
const pointerEvents = enabled ? 'box-none' : 'none';

this.root && this.root.setNativeProps({ pointerEvents });
};

private root: View | null = null;

render() {
Expand Down

0 comments on commit 1bbd6ac

Please sign in to comment.