Context firing different for different sizes for some reason

This commit is contained in:
James Barnsley
2017-12-18 08:19:38 +13:00
parent 88778cb241
commit e1876c45cf
3 changed files with 13 additions and 15 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;