Skip to content

Instantly share code, notes, and snippets.

@innabelaya
Created June 4, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save innabelaya/9fdeeb11cc6f6f9156ec8fb6cb3c2f82 to your computer and use it in GitHub Desktop.
Save innabelaya/9fdeeb11cc6f6f9156ec8fb6cb3c2f82 to your computer and use it in GitHub Desktop.
// touch.blocks/Button/Button.js
import { decl } from 'bem-react-core';
export default decl({
block : 'Button',
willInit() {
this.state = {};
this.onPointerpress = this.onPointerpress.bind(this);
this.onPointerrelease = this.onPointerrelease.bind(this);
},
mods() {
return { pressed : this.state.pressed };
}
attrs({ type }) {
return {
...this.__base(...arguments),
onPointerpress : this.onPointerpress,
onPointerrelease : this.onPointerrelease
};
},
onPointerpress() {
this.setState({ pressed : true });
},
onPointerrelease() {
this.setState({ pressed : false });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment