Add context menu to switch filters from or to and
Signed-off-by: trivernis <trivernis@protonmail.com>pull/4/head
parent
349d1dfc31
commit
69c188d288
@ -0,0 +1,5 @@
|
|||||||
|
<div class="menu-anchor" [matMenuTriggerFor]="contextMenu" [style.left]="x" [style.top]="y"></div>
|
||||||
|
<mat-menu #contextMenu="matMenu">
|
||||||
|
<ng-content select="mat-menu-item"></ng-content>
|
||||||
|
<ng-content ></ng-content>
|
||||||
|
</mat-menu>
|
@ -0,0 +1,4 @@
|
|||||||
|
.menu-anchor {
|
||||||
|
visibility: hidden;
|
||||||
|
position: fixed;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ContextMenuComponent } from './context-menu.component';
|
||||||
|
|
||||||
|
describe('ContextMenuComponent', () => {
|
||||||
|
let component: ContextMenuComponent;
|
||||||
|
let fixture: ComponentFixture<ContextMenuComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ ContextMenuComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ContextMenuComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,32 @@
|
|||||||
|
import {
|
||||||
|
Component,
|
||||||
|
ComponentFactoryResolver,
|
||||||
|
OnInit,
|
||||||
|
ViewChild,
|
||||||
|
ViewContainerRef
|
||||||
|
} from '@angular/core';
|
||||||
|
import {MatMenuTrigger} from "@angular/material/menu";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-context-menu',
|
||||||
|
templateUrl: './context-menu.component.html',
|
||||||
|
styleUrls: ['./context-menu.component.scss']
|
||||||
|
})
|
||||||
|
export class ContextMenuComponent {
|
||||||
|
|
||||||
|
|
||||||
|
public x: string = "0";
|
||||||
|
public y: string = "0";
|
||||||
|
|
||||||
|
@ViewChild(MatMenuTrigger) menuTrigger!: MatMenuTrigger
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public onContextMenu(event: MouseEvent) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.x = event.clientX + "px";
|
||||||
|
this.y = event.clientY + "px";
|
||||||
|
this.menuTrigger.openMenu();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue