All files / src/components/zd-grid view-navigator.ts

100% Statements 15/15
100% Branches 4/4
100% Functions 5/5
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31      93x 253x     4x       3x 2x       3x 2x       26x 3x       26x 3x      
import { IEventParam } from '@zeedhi/core';
import { Direction, IViewNavigator } from './interfaces';
 
export class ViewNavigator implements IViewNavigator {
	protected viewNavigate: ((direction: Direction, event?: Event) => void) | null = null;
 
	public setViewNavigate(viewNavigate: (direction: Direction, event?: Event) => void) {
		this.viewNavigate = viewNavigate;
	}
 
	public navigateLeft({ event }: IEventParam<any>) {
		if (!this.viewNavigate) return;
		this.viewNavigate('left', event);
	}
 
	public navigateRight({ event }: IEventParam<any>) {
		if (!this.viewNavigate) return;
		this.viewNavigate('right', event);
	}
 
	public navigateUp() {
		if (!this.viewNavigate) return;
		this.viewNavigate('up');
	}
 
	public navigateDown() {
		if (!this.viewNavigate) return;
		this.viewNavigate('down');
	}
}