Skip to content

Commit

Permalink
Apply sub-base pixel offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Mar 3, 2015
1 parent 1304bea commit 6f06995
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/GenomeTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var NonEmptyGenomeTrack = React.createClass({
originalScale = this.getScale();
};
var updateRange = () => {
var newStart = originalScale.invert(dx),
var newStart = originalScale.invert(-dx),
intStart = Math.round(newStart),
offsetPx = originalScale(newStart) - originalScale(intStart);

Expand Down Expand Up @@ -87,10 +87,11 @@ var NonEmptyGenomeTrack = React.createClass({
getScale: function() {
var div = this.getDOMNode(),
range = this.props.range,
width = div.offsetWidth;
width = div.offsetWidth,
offsetPx = range.offsetPx || 0;
var scale = d3.scale.linear()
.domain([range.start, range.stop + 1]) // 1 bp wide
.range([0, width]);
.range([-offsetPx, width - offsetPx]);
return scale;
},
componentDidUpdate: function(prevProps: any, prevState: any) {
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ genome.getFeaturesInRange('chr22', 19178140, 19178170).then(basePairs => {
}
}).done();

// pre-load some data to allow network-free panning
genome.getFeaturesInRange('chr1', 123000, 124000).done();

var root = React.render(<Root referenceSource={genome} />,
document.getElementById('root'));

0 comments on commit 6f06995

Please sign in to comment.