Skip to content

Commit

Permalink
Fixed scroll-to-match for text searches
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanka committed Feb 4, 2018
1 parent 2974c57 commit 8ee8593
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions client/src/visualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ Util.profileStart('rows');
var text;
if (rtlmode) {
text = svg.text(sentNumGroup, canvasWidth - sentNumMargin + Configuration.visual.margin.x, y - rowPadding,
'' + row.sentence, { 'data-sent': row.sentence });
'' + row.sentence, { 'data-sent': row.sentence });
} else {
text = svg.text(sentNumGroup, sentNumMargin - Configuration.visual.margin.x, y - rowPadding,
'' + row.sentence, { 'data-sent': row.sentence });
Expand Down Expand Up @@ -2835,8 +2835,8 @@ Util.profileStart('chunkFinish');
var nextChunk = data.chunks[chunkNo + 1];
var nextSpace = nextChunk ? nextChunk.space : '';
if (rtlmode) {
// Render every text chunk as a SVG text so we maintain control over the layout. When
// rendering as a SVG span (as brat does), then the browser changes the layout on the
// Render every text chunk as a SVG text so we maintain control over the layout. When
// rendering as a SVG span (as brat does), then the browser changes the layout on the
// X-axis as it likes in RTL mode.
svg.text(textGroup, chunk.textX, chunk.row.textY, chunk.text + nextSpace, {
'data-chunk-id': chunk.index
Expand Down
11 changes: 7 additions & 4 deletions client/src/visualizer_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ var VisualizerUI = (function($, window, undefined) {
width: 500
});


/* XXX removed per #900
// insert the Save link
var $fileBrowserButtonset = fileBrowser.
Expand Down Expand Up @@ -1684,9 +1685,10 @@ var VisualizerUI = (function($, window, undefined) {
// we may need to move to a different collection.
var oldDocCmpts = selectorData.items[pos][2].rsplit('/', 1);
if (newDocCmpts[0] != oldDocCmpts[0]) {
dispatcher.post('setCollection', [searchColl + newDocCmpts[0] + '/']);
dispatcher.post('setCollection', [searchColl + newDocCmpts[0] + '/', newDocCmpts[1], newDocArgs]);
} else {
dispatcher.post('setDocument', [newDocCmpts[1], newDocArgs]);
}
dispatcher.post('setDocument', [newDocCmpts[1], newDocArgs]);
}
return false;
};
Expand Down Expand Up @@ -1803,11 +1805,12 @@ var VisualizerUI = (function($, window, undefined) {
var svgtop = $('svg').offset().top;
var $inFocus = $('#svg animate[data-type="focus"]:first').parent();
if (!$inFocus.length && args.matchfocus) {
$inFocus = $('[data-span-id=' + args.matchfocus + ']');
$inFocus = $('#svg animate[data-type="matchfocus"]').parent();
}
if ($inFocus.length) {
$('html,body').
animate({ scrollTop: $inFocus.offset().top - svgtop - window.innerHeight / 2 }, { duration: 'slow', easing: 'swing'});
animate({ scrollTop: $inFocus.offset().top - svgtop - window.innerHeight / 2 },
{ duration: 'slow', easing: 'swing' });
}
}
dispatcher.post('allowReloadByURL');
Expand Down

0 comments on commit 8ee8593

Please sign in to comment.