diff --git a/src/js/components/Track.js b/src/js/components/Track.js index 66f42909..d3511b71 100755 --- a/src/js/components/Track.js +++ b/src/js/components/Track.js @@ -19,7 +19,7 @@ export default class Track extends React.Component{ hover: false } - this.last_touchstart = 0; + this.start_time = 0; this.start_position = false } @@ -113,7 +113,7 @@ export default class Track extends React.Component{ return false; // We started a touchstart within 300ms ago, so handle as double-tap - } else if ((timestamp - this.last_touchstart) > 0 && (timestamp - this.last_touchstart) <= 300){ + } else if ((timestamp - this.start_time) > 0 && (timestamp - this.start_time) <= 300){ // Update our selection. By not passing touch = true selection will work like a regular click this.props.handleSelection(e); @@ -140,22 +140,19 @@ export default class Track extends React.Component{ // Touch contextable } else if (target.hasClass('touch-contextable')){ + console.log('touch-contextable'); + // Update our selection. By not passing touch = true selection will work like a regular click this.props.handleSelection(e); - - // Wait a moment to give Redux time to update our selected tracks - // TODO: Use proper callback, rather than assuming a fixed period of time for store change - setTimeout(() => { - this.handleContextMenu(e); - }, - 100 - ); - e.preventDefault(); - + this.handleContextMenu(e); } - // Save our last tap - this.last_touchstart = timestamp; + // Save touch start details + this.start_time = timestamp; + this.start_position = { + x: e.touches[0].clientX, + y: e.touches[0].clientY + } return false; } diff --git a/src/js/components/TrackList.js b/src/js/components/TrackList.js index 2a30b0fc..7464d307 100755 --- a/src/js/components/TrackList.js +++ b/src/js/components/TrackList.js @@ -182,7 +182,6 @@ class TrackList extends React.Component{ } handleContextMenu(e,track_key = null){ - console.log(track_key); let selected_tracks = this.props.selected_tracks // Not already selected, so select it prior to triggering menu diff --git a/src/js/services/ui/actions.js b/src/js/services/ui/actions.js index b2de250f..8985dc49 100755 --- a/src/js/services/ui/actions.js +++ b/src/js/services/ui/actions.js @@ -13,6 +13,8 @@ export function setSelectedTracks(keys = []){ export function showContextMenu(data){ + console.log(data.e); + if (data.e.touches){ data.position_x = data.e.touches[0].clientX; data.position_y = data.e.touches[0].clientY;