Skip to content

Commit

Permalink
Bugfixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jbicker committed Feb 7, 2019
1 parent 1356eb2 commit 023c077
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion timeline-chart/src/layer/time-graph-chart-cursors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class TimeGraphChartCursors extends TimeGraphChartLayer {
return rowElementModel.range.start > cursorPosition;
});
if (nextIndex < states.length) {
const newPos = states[nextIndex].range.start;
const newPos = states[nextIndex] ? states[nextIndex].range.start : this.unitController.absoluteRange;
if (this.unitController.selectionRange && this.shiftKeyDown) {
this.unitController.selectionRange = { start: this.unitController.selectionRange.start, end: newPos };
} else {
Expand Down
10 changes: 8 additions & 2 deletions timeline-chart/src/layer/time-graph-chart-selection-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export class TimeGraphChartSelectionRange extends TimeGraphLayer {
this.unitController.onSelectionRangeChange(() => this.update());
}

protected removeSelectionRange() {
this.removeChildren();
delete this.selectionRange;
}

update() {
if (this.unitController.selectionRange) {
const firstCursorPosition = this.getPixels(this.unitController.selectionRange.start - this.unitController.viewRange.start);
Expand Down Expand Up @@ -57,9 +62,10 @@ export class TimeGraphChartSelectionRange extends TimeGraphLayer {
})
}
} else {
this.removeChildren();
delete this.selectionRange;
this.removeSelectionRange();
}
} else {
this.removeSelectionRange();
}
}
}
28 changes: 15 additions & 13 deletions timeline-chart/src/layer/time-graph-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,25 @@ export class TimeGraphChart extends TimeGraphChartLayer {
return this.selectedElementModel;
}

selectRowElement(model: TimelineChart.TimeGraphRowElementModel) {
selectRowElement(model: TimelineChart.TimeGraphRowElementModel | undefined) {
if (this.selectedElementModel) {
delete this.selectedElementModel.selected;
this.updateElementStyle(this.selectedElementModel);
}
this.selectedElementModel = model;
model.selected = true;
this.updateElementStyle(this.selectedElementModel);
const el = this.getElementById(model.id);
if (el) {
const row = el.row;
if (row) {
const newEl = this.createNewRowElement(model, row);
this.removeChild(el);
this.addElementInteractions(newEl);
this.addChild(newEl);
this.selectRow(newEl.row.model);
if (model) {
this.selectedElementModel = model;
model.selected = true;
this.updateElementStyle(this.selectedElementModel);
const el = this.getElementById(model.id);
if (el) {
const row = el.row;
if (row) {
const newEl = this.createNewRowElement(model, row);
this.removeChild(el);
this.addElementInteractions(newEl);
this.addChild(newEl);
this.selectRow(newEl.row.model);
}
}
}
this.handleSelectedRowElementChange();
Expand Down
4 changes: 3 additions & 1 deletion timeline-chart/src/layer/time-graph-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ export abstract class TimeGraphLayer {
}

protected removeChild(child: TimeGraphComponent) {
const idx = this.children.findIndex(c => c === child);
idx && this.children.splice(idx, 1);
this.layer.removeChild(child.displayObject);
}

protected getPixels(ticks: number){
protected getPixels(ticks: number) {
return ticks * this.stateController.zoomFactor;
}

Expand Down

0 comments on commit 023c077

Please sign in to comment.