Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
Show First 20 Lines • Show All 1,352 Lines • ▼ Show 20 Lines | _getVisibleChangeset: function() { | ||||
// Never show the banner if we're very near the top of the page. | // Never show the banner if we're very near the top of the page. | ||||
var margin = 480; | var margin = 480; | ||||
var s = JX.Vector.getScroll(); | var s = JX.Vector.getScroll(); | ||||
if (s.y < margin) { | if (s.y < margin) { | ||||
return null; | return null; | ||||
} | } | ||||
var v = JX.Vector.getViewport(); | // We're going to find the changeset which spans an invisible line a | ||||
// little underneath the bottom of the banner. This makes the header | |||||
// tick over from "A.txt" to "B.txt" just as "A.txt" scrolls completely | |||||
// offscreen. | |||||
var detect_height = 64; | |||||
for (var ii = 0; ii < this._changesets.length; ii++) { | for (var ii = 0; ii < this._changesets.length; ii++) { | ||||
var changeset = this._changesets[ii]; | var changeset = this._changesets[ii]; | ||||
var c = changeset.getVectors(); | var c = changeset.getVectors(); | ||||
// If the changeset starts above the upper half of the screen... | // If the changeset starts above the line... | ||||
if (c.pos.y < (s.y + (v.y / 2))) { | if (c.pos.y <= (s.y + detect_height)) { | ||||
// ...and ends below the lower half of the screen, this is the | // ...and ends below the line, this is the current visible changeset. | ||||
// current visible changeset. | if ((c.pos.y + c.dim.y) >= (s.y + detect_height)) { | ||||
if ((c.pos.y + c.dim.y) > (s.y + (v.y / 2))) { | |||||
return changeset; | return changeset; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
}); | }); |