-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force ripple via props? #24
Comments
I like this. What kind of API would you like to see here? One idea is to use refs and methods on the Ink component itself: React.createClass({
triggerRipple() {
// I'm thinking a percentage value between 0 and 1
// to prevent the need to know about the dimensions of the canvas for x/y
this.refs.ink.trigger({ x: 0.5, y: 0.5 })
},
render() {
return (
<button onMouseOver={ this.triggerRiple }><Ink ref="ink" /></button>
)
}
}) Hmm. Maybe even a const ripple = this.refs.ink.press({ x: 0.5, y: 0.5 })
setTimeout(function() {
ripple.release()
}, 500) What would work best for your app? |
I haven't studied the internals of import React from 'react';
import Ink from 'react-ink';
const Button = (props) => (
<button>
<Ink touched={true}/>
</button>
); You could imagine that a boolean prop like One could also assume centered coordinates for the ripple if not are specified, which I think might be the common use case. To elaborate on the above example, here's how I would use it: import React from 'react';
import Ink from 'react-ink';
class Button extends React.Component {
constructor(props) {
super(props);
this.onBlur = this.onBlur.bind(this);
this.onFocus = this.onFocus.bind(this);
}
onBlur(event) {
this.setState({ hasFocus: false });
}
onFocus(event) {
this.setState({ hasFocus: true });
}
render() {
const inkProps = {};
if (this.state.hasFocus) {
inkProps.touched = this.state.hasFocus;
}
return (
<button onBlur={this.onBlur} onFocus={this.onFocus}>
<Ink {...inkProps}/>
</button>
);
}
} This example will set the |
Your suggestion might be easier to work – but I've traditionally avoid externalizing methods on components. |
@mshwery Sorry for the delay. I like that better myself. |
And I like to send my comments too early! I'm happy to crank on this, however I probably won't be able to get to it until next week. |
I was hoping I could achieve forcing the ripple to appear (centered as requested in #22) programmatically. This would enable one to use the focus state on a button to have the ripple appear and then disappear on blur.
The text was updated successfully, but these errors were encountered: