Skip to content
Snippets Groups Projects
Commit 9607b4ac authored by mathias.chouet's avatar mathias.chouet
Browse files

Restrict up/down key inhibition to number inputs only

parent 7fd0f89c
No related branches found
No related tags found
No related merge requests found
......@@ -716,27 +716,11 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
}
}
/**
* Disable value modification on mouse wheel or up/down arrows, in input type="number"
*/
/* @HostListener("mousewheel", [ "$event" ]) onMouseWheelChrome(event: any) {
this.disableScroll(event);
}
@HostListener("DOMMouseScroll", [ "$event" ]) onMouseWheelFirefox(event: any) {
this.disableScroll(event);
}
@HostListener("onmousewheel", [ "$event" ]) onMouseWheelIE(event: any) {
this.disableScroll(event);
}
disableScroll(event: any) {
if (event.srcElement.type === "number") {
event.preventDefault();
// @TODO how to send event to parent (or Window ?) so that scrolling the page works ?
}
} */
@HostListener("keydown", [ "$event" ]) onKeydown(event: any) {
if (event.which === 38 || event.which === 40) { // up / down arrow
event.preventDefault();
if (event.srcElement.type === "number") {
event.preventDefault();
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment