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

Proxy measurement methods from the Ripple #149

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
11 changes: 10 additions & 1 deletion lib/Ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class Ripple extends Component {
return (
<PolyfillRipple
rippleColor={color}
ref={this._setMainRef}
onPress={onPress}
onLongPress={onLongPress}
{...other}
Expand All @@ -41,12 +42,20 @@ export default class Ripple extends Component {
onPress={onPress}
onLongPress={onLongPress}
>
<View {...other}>
<View ref={this._setMainRef} {...other}>
{children}
</View>
</TouchableNativeFeedback>
);
}

_setMainRef = (ref) => {
this.main = ref;
};

// Proxy the measurement methods from the main view
measure = (...args) => this.main.measure(...args);
measureInWindow = (...args) => this.main.measureInWindow(...args);
measureLayout = (...args) => this.main.measureLayout(...args);
}

9 changes: 9 additions & 0 deletions lib/polyfill/Ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class Ripple extends Component {
onPressOut={this._unHighlight}
>
<View
ref={this._setMainRef}
style={[elevationPolyfill(elevation ? elevation : 0), outerStyle]}
>
<View ref="container" style={[styles.container, innerStyle]}>
Expand Down Expand Up @@ -168,6 +169,14 @@ export default class Ripple extends Component {
})
};

_setMainRef = (ref) => {
this.main = ref;
};

// Proxy the measurement methods from the main view
measure = (...args) => this.main.measure(...args);
measureInWindow = (...args) => this.main.measureInWindow(...args);
measureLayout = (...args) => this.main.measureLayout(...args);
}

const styles = {
Expand Down