projects/i-components/src/lib/components/xam-tile-splitter/xam-tile-splitter.component.ts
Angular Component for the XamTile splitter.
selector | wm-xam-tile-splitter |
styleUrls | ./xam-tile-splitter.component.scss |
templateUrl | ./xam-tile-splitter.component.html |
Properties |
|
Methods |
|
Inputs |
HostBindings |
HostListeners |
Accessors |
constructor(element?: ElementRef, xamTileService?: XamTileManagerService)
|
|||||||||
Creates an instance of XamTileSplitterComponent.
Parameters :
|
gridArea | |
Type : string
|
|
Gets the gridArea CSS property to apply. |
isHorizontal | |
Type : boolean
|
|
If the value is true means that the splitter is in a horizontal position, otherwise is in vertical position. |
isTransparent | |
Type : boolean
|
|
Default value : false
|
|
Flag to indicate the component should be transparent |
class.toBottom |
Type : boolean
|
Class to apply when the splitter is vertical (sticks to the bottom) |
class.toRight |
Type : boolean
|
Class to apply when the splitter is vertical (sticks to the right) |
class.withBorder |
Type : boolean
|
To show or not border depending on if is transparent |
mousedown |
mousedown(event: any)
|
Mousedown event handler. |
Private calcPosition |
calcPosition()
|
Calculates the current position where thes splitter is located
Returns :
void
|
mouseDownHandler | ||||||
mouseDownHandler(event: any)
|
||||||
Decorators :
@HostListener('mousedown')
|
||||||
Mousedown event handler.
Parameters :
Returns :
void
|
Private _gridArea |
Type : string
|
Default value : null
|
Internal variable for the grid area to apply to the grid |
Private _isHorizontal |
Default value : false
|
Internal variable for the property isHorizontal |
Public currentPosition |
Type : number
|
Default value : null
|
Current position of the splitter in the host grid |
Public isSplitterMoving |
Default value : false
|
Property to know if the splitter is moving. |
Public isTransparent |
Default value : false
|
Decorators :
@Input()
|
Flag to indicate the component should be transparent |
gridArea | ||||||
getgridArea()
|
||||||
Gets the gridArea CSS property to apply.
Returns :
string
|
||||||
setgridArea(value: string)
|
||||||
Sets the gridArea CSS property to apply.
Parameters :
Returns :
void
|
isHorizontal | ||||||
getisHorizontal()
|
||||||
If the value is true means that the splitter is in a horizontal position, otherwise is in vertical position.
Returns :
boolean
|
||||||
setisHorizontal(value: boolean)
|
||||||
Sets the value for isHorizontal
Parameters :
Returns :
void
|
toRight |
gettoRight()
|
Class to apply when the splitter is vertical (sticks to the right)
Returns :
boolean
|
toBottom |
gettoBottom()
|
Class to apply when the splitter is vertical (sticks to the bottom)
Returns :
boolean
|
withBorder |
getwithBorder()
|
To show or not border depending on if is transparent
Returns :
boolean
|
import {
Component,
ElementRef,
Input,
HostBinding,
HostListener,
} from '@angular/core';
import { XamTileManagerService } from '../xam-tile-manager/xam-tile-manager.service';
/**
* Angular Component for the XamTile splitter.
*
* @export
* @class XamTileSplitterComponent
*/
@Component({
selector: 'wm-xam-tile-splitter',
templateUrl: './xam-tile-splitter.component.html',
styleUrls: ['./xam-tile-splitter.component.scss'],
})
export class XamTileSplitterComponent {
/**
* Current position of the splitter in the host grid
*
* @type {number}
* @memberof XamTileSplitterComponent
*/
public currentPosition: number = null;
/**
* Internal variable for the grid area to apply to the grid
*
* @private
* @type {string}
* @memberof XamTileSplitterComponent
*/
private _gridArea: string = null;
/**
* Internal variable for the property isHorizontal
*
* @private
* @type {boolean}
* @memberof XamTileSplitterComponent
*/
private _isHorizontal = false;
/**
* Gets the gridArea CSS property to apply.
*
* @type {string}
* @memberof XamTileSplitterComponent
*/
@Input()
@HostBinding('style.gridArea')
public get gridArea(): string {
return this._gridArea;
}
/**
* Sets the gridArea CSS property to apply.
*
* @memberof XamTileSplitterComponent
*/
public set gridArea(value: string) {
this._gridArea = value;
this.calcPosition();
}
/**
* If the value is true means that the splitter is in a horizontal position, otherwise is in vertical position.
*
* @type {boolean}
* @memberof XamTileSplitterComponent
*/
@Input()
public get isHorizontal(): boolean {
return this._isHorizontal;
}
/**
* Sets the value for isHorizontal
*
* @memberof XamTileSplitterComponent
*/
public set isHorizontal(value: boolean) {
this._isHorizontal = !!value;
this.calcPosition();
}
/**
* Class to apply when the splitter is vertical (sticks to the right)
*
* @type {string}
* @memberof XamTileSplitterComponent
*/
@HostBinding('class.toRight')
get toRight(): boolean {
return !this.isHorizontal;
}
/**
* Class to apply when the splitter is vertical (sticks to the bottom)
*
* @readonly
* @type {boolean}
* @memberof XamTileSplitterComponent
*/
@HostBinding('class.toBottom')
get toBottom(): boolean {
return this.isHorizontal;
}
/**
* To show or not border depending on if is transparent
*
* @readonly
* @type {boolean}
* @memberof XamTileSplitterComponent
*/
@HostBinding('class.withBorder')
get withBorder(): boolean {
return !this.isTransparent;
}
/**
* Flag to indicate the component should be transparent
*
* @private
* @type {boolean}
* @memberof XamTileSplitterComponent
*/
@Input()
public isTransparent = false;
/**
* Property to know if the splitter is moving.
*
* @type {boolean}
* @memberof XamTileSplitterComponent
*/
public isSplitterMoving = false;
/**
* Creates an instance of XamTileSplitterComponent.
*
* @param {ElementRef} element
* @memberof XamTileSplitterComponent
*/
constructor(
private element?: ElementRef,
private xamTileService?: XamTileManagerService
) {}
/**
* Calculates the current position where thes splitter is located
*
* @private
* @memberof XamTileSplitterComponent
*/
private calcPosition(): void {
if (!!this.gridArea) {
const idx = this.isHorizontal ? 0 : 1;
this.currentPosition = Number.parseInt(this.gridArea.split('/')[idx]) - 1;
} else this.currentPosition = null;
}
/**
* Mousedown event handler.
*
* @memberof XamTileSplitterComponent
*/
@HostListener('mousedown')
mouseDownHandler(event: any): void {
this.isSplitterMoving = true;
this.xamTileService.notifyTileResizing(true);
}
}
<div class="splitter" [class]="{ splitterWithBackground: !isTransparent }">
<igx-icon *ngIf="!isTransparent" color="#868686">{{
isHorizontal ? 'more_horiz' : 'more_vert'
}}</igx-icon>
</div>
./xam-tile-splitter.component.scss
@import '../../scss/variables';
:host {
.splitter {
height: 100%;
width: 100%;
display: flex;
user-select: none;
isolation: isolate;
align-items: center;
justify-content: center;
pointer-events: all;
}
.splitterWithBackground {
background: $xam-tile-splitter-background-color;
}
&.toRight {
height: 100%;
width: 5px;
margin-left: auto;
cursor: ew-resize;
}
&.toBottom {
height: 5px;
width: 100%;
align-self: flex-end;
cursor: ns-resize;
}
&.withBorder {
border: $xam-tile-splitter-border;
box-sizing: border-box;
}
}