add selection by mouse over
This commit is contained in:
parent
2b053a9d47
commit
09ff3a751d
@ -14,13 +14,16 @@ export class Table extends ExcelComponent {
|
|||||||
static className = 'excel__table';
|
static className = 'excel__table';
|
||||||
|
|
||||||
private selection: TableSelection;
|
private selection: TableSelection;
|
||||||
|
private isMouseDowned: boolean;
|
||||||
|
|
||||||
constructor($root: Dom, options: ComponentOptionsType) {
|
constructor($root: Dom, options: ComponentOptionsType) {
|
||||||
super($root, {
|
super($root, {
|
||||||
...options,
|
...options,
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
eventListeners: ['mousedown', 'keydown', 'input'],
|
eventListeners: ['mousedown', 'keydown', 'input', 'mouseover', 'mouseup'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.isMouseDowned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
toHTML(): string {
|
toHTML(): string {
|
||||||
@ -123,6 +126,7 @@ export class Table extends ExcelComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMousedown(event: MouseEvent) {
|
onMousedown(event: MouseEvent) {
|
||||||
|
this.isMouseDowned = true;
|
||||||
selectHandler(event, this.selection, this.emitSelectCallback.bind(this));
|
selectHandler(event, this.selection, this.emitSelectCallback.bind(this));
|
||||||
this.resizeTable(event);
|
this.resizeTable(event);
|
||||||
}
|
}
|
||||||
@ -134,4 +138,12 @@ export class Table extends ExcelComponent {
|
|||||||
onInput(event: InputEvent) {
|
onInput(event: InputEvent) {
|
||||||
this.updateCurrentText((event.target as HTMLElement).innerText);
|
this.updateCurrentText((event.target as HTMLElement).innerText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMouseover(event: MouseEvent) {
|
||||||
|
this.isMouseDowned && selectHandler(event, this.selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseup() {
|
||||||
|
this.isMouseDowned = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,17 @@ export function selectHandler(event: MouseEvent | KeyboardEvent, selection: Tabl
|
|||||||
onMouseDownHandler();
|
onMouseDownHandler();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'keydown': {
|
case 'keydown': {
|
||||||
onKeyDownHandler();
|
onKeyDownHandler();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'mouseover': {
|
||||||
|
onMouseOverHandler();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,4 +106,10 @@ export function selectHandler(event: MouseEvent | KeyboardEvent, selection: Tabl
|
|||||||
|
|
||||||
selection.selectByCellId({ row, col });
|
selection.selectByCellId({ row, col });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onMouseOverHandler() {
|
||||||
|
if (selection.current.$el) {
|
||||||
|
selection.selectTo($((event as any).toElement));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user