import { AfterViewInit , ChangeDetectionStrategy , Component , ContentChildren , QueryList } from '@angular/core' ; import { ItemFrameValueComponent } from '../item-frame-value/item-frame-value.component' ; @ Component ( { selector : 'app-item-frame-value-group' , templateUrl : './item-frame-value-group.component.html' , styleUrls : [ './item-frame-value-group.component.scss' ] , changeDetection : ChangeDetectionStrategy . OnPush } ) export class ItemFrameValueGroupComponent implements AfterViewInit { private children : ItemFrameValueComponent [ ] ; @ ContentChildren ( ItemFrameValueComponent , { descendants : true } ) public values : QueryList < ItemFrameValueComponent > ; public ngAfterViewInit ( ) { this . children = this . values . toArray ( ) ; } public onMouseDown ( event ) { const target = event . target as HTMLInputElement ; if ( target ?. tagName === 'INPUT' ) { return ; } event . preventDefault ( ) ; event . stopImmediatePropagation ( ) ; } public onMouseUp ( event ) { event . preventDefault ( ) ; event . stopImmediatePropagation ( ) ; if ( event . which === 2 ) { this . children . forEach ( x => x . resetValue ( true , true ) ) ; } else if ( event . which === 3 ) { this . children . forEach ( x => x . toggleValue ( true , true ) ) ; } } public onWheel ( event ) { event . preventDefault ( ) ; event . stopImmediatePropagation ( ) ; this . children . forEach ( x => x . adjustValue ( x . getStepFromEvent ( event ) , true , true ) ) ; } }