Skip to content
Snippets Groups Projects
Commit 6eae95f9 authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: scroll first highlighted/selected element into view

parent b44ed7c4
Branches
No related tags found
No related merge requests found
...@@ -153,6 +153,8 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { ...@@ -153,6 +153,8 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> {
const { markerArray } = this.props.sequenceWrapper; const { markerArray } = this.props.sequenceWrapper;
const hasNumbers = !this.props.hideSequenceNumbers, period = this.sequenceNumberPeriod; const hasNumbers = !this.props.hideSequenceNumbers, period = this.sequenceNumberPeriod;
let first: HTMLSpanElement | undefined;
let o = 0; let o = 0;
for (let i = 0, il = markerArray.length; i < il; i++) { for (let i = 0, il = markerArray.length; i < il; i++) {
if (hasNumbers && i % period === 0 && i < il) o++; if (hasNumbers && i % period === 0 && i < il) o++;
...@@ -160,9 +162,17 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { ...@@ -160,9 +162,17 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> {
if (!span) return; if (!span) return;
o++; o++;
if (!first && markerArray[i] > 0) {
first = span;
}
const backgroundColor = this.getBackgroundColor(markerArray[i]); const backgroundColor = this.getBackgroundColor(markerArray[i]);
if (span.style.backgroundColor !== backgroundColor) span.style.backgroundColor = backgroundColor; if (span.style.backgroundColor !== backgroundColor) span.style.backgroundColor = backgroundColor;
} }
if (first) {
first.scrollIntoView({ block: 'nearest' });
}
} }
mouseMove = (e: React.MouseEvent) => { mouseMove = (e: React.MouseEvent) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment