From cdd0bfec0c208d6ac22a3b5bf0f88ddefff175ee Mon Sep 17 00:00:00 2001 From: smuddyx Date: Sun, 19 Apr 2020 14:57:58 +0200 Subject: [PATCH] adding scroll behaviour to presentation mode --- .../monitor/monitor.component.html | 5 +-- .../monitor/monitor.component.less | 4 +++ .../presentation/monitor/monitor.component.ts | 2 +- .../presentation/remote/remote.component.html | 8 +++-- .../presentation/remote/remote.component.less | 4 +-- .../components/song-text/animation.ts | 18 ++++++++++ .../song-text/song-text.component.html | 12 +++++-- .../song-text/song-text.component.less | 20 +++++++++-- .../song-text/song-text.component.ts | 33 +++++++++++++++---- src/styles/styles.less | 4 +++ 10 files changed, 90 insertions(+), 20 deletions(-) create mode 100644 src/app/widget-modules/components/song-text/animation.ts diff --git a/src/app/modules/presentation/monitor/monitor.component.html b/src/app/modules/presentation/monitor/monitor.component.html index ba8e6e9..dd51db8 100644 --- a/src/app/modules/presentation/monitor/monitor.component.html +++ b/src/app/modules/presentation/monitor/monitor.component.html @@ -1,4 +1,5 @@ -
- +
+
diff --git a/src/app/modules/presentation/monitor/monitor.component.less b/src/app/modules/presentation/monitor/monitor.component.less index 6f08e3d..6ff459d 100644 --- a/src/app/modules/presentation/monitor/monitor.component.less +++ b/src/app/modules/presentation/monitor/monitor.component.less @@ -1,3 +1,7 @@ +:host { + margin-top: 0 !important; +} + .fullscreen { position: fixed; top: 0; diff --git a/src/app/modules/presentation/monitor/monitor.component.ts b/src/app/modules/presentation/monitor/monitor.component.ts index 928546c..3a0a129 100644 --- a/src/app/modules/presentation/monitor/monitor.component.ts +++ b/src/app/modules/presentation/monitor/monitor.component.ts @@ -14,7 +14,7 @@ import {Song} from '../../songs/services/song'; export class MonitorComponent implements OnInit { public song: Song; public zoom: number; - private index: number; + public index: number; private sections: Section[]; constructor( diff --git a/src/app/modules/presentation/remote/remote.component.html b/src/app/modules/presentation/remote/remote.component.html index 1c39fde..0099860 100644 --- a/src/app/modules/presentation/remote/remote.component.html +++ b/src/app/modules/presentation/remote/remote.component.html @@ -13,7 +13,9 @@
-
{{song.title}}
+
+
{{song.title}}
+
- + *') + transition(':enter', [ + style({opacity: 0}), + animate(600) + ]), + + // fade out when destroyed. this could also be written as transition('void => *') + transition(':leave', + animate(600, style({opacity: 0}))) + ]) diff --git a/src/app/widget-modules/components/song-text/song-text.component.html b/src/app/widget-modules/components/song-text/song-text.component.html index d3bf0a1..6317d76 100644 --- a/src/app/widget-modules/components/song-text/song-text.component.html +++ b/src/app/widget-modules/components/song-text/song-text.component.html @@ -1,10 +1,16 @@ -
+
-
-
{{line.text}}
+
+
+
{{line.text}}
+
+ +
diff --git a/src/app/widget-modules/components/song-text/song-text.component.less b/src/app/widget-modules/components/song-text/song-text.component.less index b82d80b..6727116 100644 --- a/src/app/widget-modules/components/song-text/song-text.component.less +++ b/src/app/widget-modules/components/song-text/song-text.component.less @@ -25,6 +25,15 @@ } } +.line { + opacity: 1; + transition: 1000ms all ease-in-out; + + &.disabled { + opacity: 0.5; + } +} + .menu { position: absolute; right: 0; @@ -48,8 +57,6 @@ &:hover { background: #ddd; } - - } .section { @@ -70,3 +77,12 @@ .chord { color: #009; } + +.offset { + position: fixed; + top: 0; + + transition: 1000ms all ease-in-out; +} + + diff --git a/src/app/widget-modules/components/song-text/song-text.component.ts b/src/app/widget-modules/components/song-text/song-text.component.ts index 99704ae..25d2f80 100644 --- a/src/app/widget-modules/components/song-text/song-text.component.ts +++ b/src/app/widget-modules/components/song-text/song-text.component.ts @@ -1,4 +1,4 @@ -import {Component, ElementRef, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {Component, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren} from '@angular/core'; import { Line, LineType, @@ -7,20 +7,25 @@ import { TextRenderingService } from '../../../modules/songs/services/text-rendering.service'; import {faGripLines} from '@fortawesome/free-solid-svg-icons/faGripLines'; +import {songSwitch} from './animation'; export type ChordMode = 'show' | 'hide' | 'onlyFirst' @Component({ selector: 'app-song-text', templateUrl: './song-text.component.html', - styleUrls: ['./song-text.component.less'] + styleUrls: ['./song-text.component.less'], + animations: [songSwitch], }) export class SongTextComponent implements OnInit { public sections: Section[]; - @Input() public scrollIndex = 0; - @Input() showSwitch = false; + @Input() public index = -1; + @Input() public fullscreen = false; + @Input() public showSwitch = false; @Output() public chordModeChanged = new EventEmitter(); + @ViewChildren('section') viewSections: QueryList; public faLines = faGripLines; + public offset = 0; constructor(private textRenderingService: TextRenderingService, private elRef: ElementRef) { } @@ -34,11 +39,22 @@ export class SongTextComponent implements OnInit { @Input() public set text(value: string) { - this.sections = this.textRenderingService.parse(value).sort((a, b) => a.type - b.type); - console.log(this.sections) + this.sections = null; + this.offset = 0; + setTimeout(() => + this.sections = this.textRenderingService.parse(value).sort((a, b) => a.type - b.type), 100); } + ngOnInit(): void { + setInterval(() => { + if (!this.fullscreen || this.index === -1) { + this.offset = 0; + return; + } + this.offset = -this.viewSections.toArray()[this.index].nativeElement.offsetTop; + } + , 100); } public getLines(section: Section): Line[] { @@ -77,4 +93,9 @@ export class SongTextComponent implements OnInit { return 'show'; } } + + checkDisabled(i: number) { + return this.index !== -1 && this.index !== i; + + } } diff --git a/src/styles/styles.less b/src/styles/styles.less index 29929bc..1a44991 100644 --- a/src/styles/styles.less +++ b/src/styles/styles.less @@ -33,6 +33,10 @@ h1, h2, h3, h4 { margin: 0 0 20px 0; } +.mat-form-field { + width: 100%; +} + .mat-form-field .mat-form-field-infix { width: unset; }