Skip to content

Commit

Permalink
Added code to detect touch inputs on resizer div
Browse files Browse the repository at this point in the history
Added code to detect touch inputs on the resizer div. Also, added
relative heights and widths to the resizer, so that it stays
within the boundaries of the video in mobile.

Bug: T245341
Change-Id: I5ab9f9cbbb0e936e093ab571e6312d210e019604
  • Loading branch information
sohomdatta1 committed Feb 21, 2020
1 parent 3eb0b07 commit da834a0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,26 @@ class home extends Component {
window.addEventListener('mouseup', stopResize);
});

resizer.addEventListener('touchstart', e => {
e.preventDefault();

original_width = getTruePropertyValue('width');
original_height = getTruePropertyValue('height');
transformValue = getTransformValue();

// taking the first touch event and
// ignoring touch events for other fingers
original_mouse_x = e.changedTouches[0].pageX;
original_mouse_y = e.changedTouches[0].pageY;

window.addEventListener('touchmove', resize);
window.addEventListener('touchend', stopResize);
});

function resize(e) {
// check if it is a touch interface,
// else do everything the usual way
e = ( e.changedTouches && e.changedTouches[0] ) || e;
switch (resizerPosition) {
case 'top-center':
top = e.pageY - original_mouse_y;
Expand Down Expand Up @@ -537,6 +556,7 @@ class home extends Component {
if (self.refs.player !== undefined) {
self.onDragStop();
window.removeEventListener('mousemove', resize);
window.removeEventListener('touchmove', resize);
}
}
});
Expand Down Expand Up @@ -1059,6 +1079,7 @@ class home extends Component {
onHeightReady={height =>
console.log("Height: " + height)
}
style={{ height: "95%", width: "95%" }}
>
<div id="draggable-area"></div>
<div className="resizers">
Expand Down

0 comments on commit da834a0

Please sign in to comment.