Skip to content

Commit

Permalink
some ui changes from the Pro repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeful committed Oct 6, 2021
1 parent b3c6dbc commit 8c71bed
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,6 @@ export class FlatSliderComponent implements OnInit, OnDestroy {
return style
}

@HostListener('window:resize')
onWindowResize () {
this.changeRef.detectChanges()
}

private mapValue ({ value, inMin, inMax, outMin, outMax, logInverse }: {
value: number
inMin: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,6 @@ export class SkeuomorphSliderComponent implements OnInit, OnDestroy {
}
}

@HostListener('window:resize')
onWindowResize () {
this.drawNotches()
this.changeRef.detectChanges()
}

drawNotches () {
const canvas = this.notches.nativeElement
const ctx: CanvasRenderingContext2D = canvas.getContext('2d')
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "3.0.1",
"version": "3.0.4",
"scripts": {
"lint": "npx eslint .",
"start": "../node_modules/.bin/ng serve --port 8080 --host 0.0.0.0 --disable-host-check",
Expand Down
31 changes: 28 additions & 3 deletions ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
Component,
OnInit,
ViewChild,
AfterContentInit
AfterContentInit,
HostListener
} from '@angular/core'
import { UtilitiesService } from './services/utilities.service'
import { UIService } from './services/ui.service'
Expand Down Expand Up @@ -43,11 +44,13 @@ export class AppComponent implements OnInit, AfterContentInit {
help: false
}

private containerWidth = 400
private containerHeight = 400
get containerStyle () {
const style: any = {}

style.width = `${100 / this.ui.scale}%`
style.height = `${100 / this.ui.scale}%`
style.width = `${this.containerWidth / this.ui.scale}px`
style.height = `${this.containerHeight / this.ui.scale}px`
style.transform = `scale(${this.ui.scale})`

return style
Expand Down Expand Up @@ -284,6 +287,28 @@ This data would help us improve and grow the product.`
}
}

private windowResizeHandlerTimer: number
@HostListener('window:resize')
handleWindowResize () {
if (this.windowResizeHandlerTimer) {
clearTimeout(this.windowResizeHandlerTimer)
}

this.windowResizeHandlerTimer = setTimeout(async () => {
const [ height, width ] = await Promise.all([
this.ui.getHeight(),
this.ui.getWidth()
])

this.containerHeight = height
this.containerWidth = width

setTimeout(() => {
this.ui.dimensionsChanged.emit()
}, 100)
}, 100) as any
}

async getTransitionSettings () {
const settings = await this.transitions.getSettings()
this.animationDuration = settings.duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class EqualizersComponent implements OnInit, OnDestroy {
await this.service.setType(type)
this.type = type
await this.utils.delay(this.animationDuration)
this.ui.dimensionsChanged.next()
}

public getEqualizerFromType (type: EqualizerType): EqualizerComponent {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/services/ui.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export enum StatusItemIconType {
})
export class UIService extends DataService {
route = `${this.route}/ui`
dimensionsChanged = new Subject<UIDimensions>()
dimensionsChanged = new EventEmitter()
settingsChanged = new Subject<UISettings>()
settings: UISettings = {}
private _scale = 1
Expand Down

0 comments on commit 8c71bed

Please sign in to comment.