Skip to content

Commit 0f53984

Browse files
committed
AEDebugging_ Better Scroll behaviour
SQUASHED: AUTO-COMMIT-src-client-reactive-components-basic-aexpr-timeline.js,AUTO-COMMIT-src-external-event-drops-dropLine.js,AUTO-COMMIT-src-external-event-drops-index.js,AUTO-COMMIT-src-external-event-drops-indicator.js,
1 parent 72a87c8 commit 0f53984

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/client/reactive/components/basic/aexpr-timeline.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export default class EventDrops extends Morph {
352352
row.append(th);
353353

354354
th.addEventListener('click', () => {
355-
this.showEvents(events);
355+
this.showEvents(events, ae);
356356
});
357357

358358
for (const event of valueChangingEvents) {
@@ -361,37 +361,39 @@ export default class EventDrops extends Morph {
361361
row.append(cell);
362362

363363
cell.addEventListener('click', () => {
364-
this.showEvents([event]);
364+
this.showEvents([event], ae);
365365
});
366366
}
367367
this.valuesOverTime.append(row);
368368
}
369369
}
370370

371-
showEvents(events) {
371+
showEvents(events, ae) {
372372
const timestamps = events.map(e => e.timestamp.getTime());
373373
const minTime = Math.min(...timestamps);
374374
const maxTime = Math.max(...timestamps);
375375
const padding = Math.max((maxTime - minTime) / 10, 10);
376-
let min = new Date(minTime - padding);
377-
let max = new Date(maxTime + padding);
378-
376+
const min = new Date(minTime - padding);
377+
const max = new Date(maxTime + padding);
378+
379+
const lineElement = this.shadowRoot.querySelectorAll(".line-label").find(element => {
380+
const dropLineName = element.innerHTML;
381+
const dropLineAEName = dropLineName.substring(0, dropLineName.lastIndexOf(" "));
382+
return (ae.meta().get('id') + " ").includes(dropLineAEName + " ");
383+
});
384+
lineElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
385+
379386
this.chart.scale().domain([min, max]);
380-
this.chart.zoomToDomain([min, max]);
381-
//Add delay to allow rerender
382-
setTimeout(() => {
387+
this.chart.zoomToDomain([min, max], 300, 0, d3.easeQuadInOut).on("end", () => {
383388
for(const event of events) {
384389
this.highlightEvent(event);
385390
}
386-
}, 30);
387-
391+
});
388392
}
389393

390394
highlightEvent(event) {
391-
const selectedDrops = this.shadowRoot.querySelectorAll(".drop[id=\"" + event.id + "\"]");
392-
for(const drop of selectedDrops) {
393-
drop.setAttribute("r", 10);
394-
}
395+
const selectedDrop = this.shadowRoot.querySelector(".drop[id=\"" + event.id + "\"]");
396+
selectedDrop.setAttribute("r", 10);
395397
}
396398

397399
updateOverview(aexprs) {

src/external/event-drops/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default (customConfiguration) => {
8686
xScale,
8787
width
8888
);
89-
svg.transition()
89+
return svg.transition()
9090
.ease(ease)
9191
.delay(delay)
9292
.duration(duration)
@@ -125,7 +125,7 @@ export default (customConfiguration) => {
125125
ease = d3.easeLinear
126126
) => {
127127
if (typeof chart._zoomToDomain === 'function') {
128-
chart._zoomToDomain(domain, duration, delay, ease);
128+
return chart._zoomToDomain(domain, duration, delay, ease);
129129
} else {
130130
throw new Error(
131131
'Calling "zoomToDomain" requires zooming to be enabled.'

0 commit comments

Comments
 (0)