import { Component, OnInit } from '@angular/core'; import { Platform, Events } from '@ionic/angular'; import { KeyboardService } from '../../services/keyboard/keyboard.service'; import { KeyboardStatusModel } from '../../services/keyboard/keyboard-status.model'; @Component({ selector: 'scroll-segment-content', templateUrl: './scroll-segment-content.component.html', styleUrls: ['./scroll-segment-content.component.scss'], }) export class ScrollSegmentContentComponent implements OnInit { public keyboardOpened = false; public className = ''; constructor( public events: Events, public keyboardService: KeyboardService, public platform: Platform ) { } ngOnInit() { this.platform.ready().then(() => { this.setClassName( ); this.monitorKeyboardChange(); }); } private monitorKeyboardChange() { this.events.subscribe(KeyboardService.KEYBOARD_STATUS, (status: KeyboardStatusModel) => { this.setClassName ( ); }); } private setClassName () { this.keyboardOpened = KeyboardService.keyboardOpened; if ( this.platform.is('ios')) { this.className = 'scroll-segment-area ios zoomIn ' + ( this.keyboardOpened ? 'keyboard-opened' : 'keyboard-closed' ); } else { this.className = 'scroll-segment-area md zoomIn ' + ( this.keyboardOpened ? 'keyboard-opened' : 'keyboard-closed' ); } } }