Skip to content

Commit

Permalink
Mitigate #350
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Nov 20, 2015
1 parent 34a1e8f commit 5337d37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/PileupTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ class PileupTrack extends React.Component {

// TODO: the center line should go above alignments, but below mismatches
this.renderCenterLine(ctx, range, scale);

// This is a hack to mitigate #350
var el = d3utils.findParent(this.refs.canvas, 'track-content');
if (el) el.scrollLeft = 0;
}

// Draw the center line(s), which orient the user
Expand Down
15 changes: 14 additions & 1 deletion src/main/d3utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,21 @@ function sizeCanvas(el: HTMLCanvasElement, width: number, height: number) {
}
}

/**
* Find the closest parent with a given class name.
*/
function findParent(inEl: Element, className: string): ?Element {
var el = inEl; // this is for Flow.
do {
if (el.classList.contains(className)) return el;
el = el.parentElement;
} while (el);
return null;
}

module.exports = {
formatRange,
getTrackScale,
sizeCanvas
sizeCanvas,
findParent
};

0 comments on commit 5337d37

Please sign in to comment.