Skip to content

Commit

Permalink
ImageInput Touch Selection
Browse files Browse the repository at this point in the history
Ref #8
  • Loading branch information
0xcaff committed Oct 8, 2017
1 parent 181a2d9 commit 07a5b10
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,23 @@ export default class Annotations extends Component {

// attach listeners to stage so we receive all mouse events, (even consumed
// ones).
stage.on('contentMousedown', withPosition(({x, y}) => {
stage.on('contentMousedown contentTouchstart', withPosition(({ x, y }, { evt }) => {
evt.preventDefault();

expandSelection(area, {x0: x, y0: y, x1: x, y1: y});
}));

stage.on('contentMousemove', withPosition(({x, y}, {evt}) => {
evt.buttons === 1 && expandSelection(area, {x1: x, y1: y});
stage.on('contentMousemove contentTouchmove', withPosition(({ x, y }, { evt }) => {
evt.preventDefault();

const isActive = evt.buttons === 1 || (evt.touches && evt.touches.length);
if (isActive) {
expandSelection(area, {x1: x, y1: y});
}
}));

stage.on('contentMouseup', withPosition(({x, y}, {evt}) => {
stage.on('contentMouseup contentTouchend', withPosition(({ x, y }, { evt }) => {
evt.preventDefault();
const { selected } = this;

expandSelection(area, {x1: x, y1: y});
Expand Down

0 comments on commit 07a5b10

Please sign in to comment.