Tracks user "scratches" or swipes.
import {ScratchSensor} from 'libreact/lib/ScratchSensor';
<ScratchSensor>{(state) =>
<div style={{
width: 300,
height: 300,
border: '1px solid tomato',
}}>
<pre style={{fontFamily: 'monospace'}}>
{JSON.stringify(state, null, 4)}
</pre>
</div>
}</ScratchSensor>
bond
— optional, boolean or string, bonding name to provide as data prop.disabled
— optional, boolean, whether to not track scratches.
Render prop receives an object with the following signature.
interface IScratchSensorState {
isScratching?: boolean;
start?: number;
end?: number;
x?: number;
y?: number;
dx?: number;
dy?: number;
docX?: number;
docY?: number;
posX?: number;
posY?: number;
elH?: number;
elW?: number;
elX?: number;
elY?: number;
}
Injects scratch
prop into your component.
import {withScratch} from 'libreact/lib/ScratchSensor';
const MyCompWithScratch = withScratch(MyComp);
Injects scratch
prop into your component.
import {withScratch} from 'libreact/lib/ScratchSensor';
@withScratch
class MyComp extends Component {
}