Skip to content
Snippets Groups Projects
Commit 4fcc0c6e authored by fsdavid's avatar fsdavid
Browse files

Resolve screenshot taking background

parent af955666
No related branches found
No related tags found
No related merge requests found
import {ChangeDetectionStrategy, Component, Input, TemplateRef } from "@angular/core";
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
Input,
TemplateRef,
ViewChild
} from "@angular/core";
import { MatBottomSheet, MatDialog, MatDialogRef } from "@angular/material";
import { select, Store } from "@ngrx/store";
import { Observable } from "rxjs";
......@@ -21,18 +29,22 @@ export class SigninBanner {
@Input() public darktheme: boolean
@Input() public parcellationIsSelected: boolean
@ViewChild('takeScreenshotElement', {read: ElementRef}) takeScreenshotElement: ElementRef
public user$: Observable<IUser>
public userBtnTooltip$: Observable<string>
public favDataEntries$: Observable<IDataEntry[]>
public pluginTooltipText: string = `Plugins and Tools`
public screenshotTooltipText: string = 'Take screenshot'
public takingScreenshot: boolean = false
constructor(
private store$: Store<IavRootStoreInterface>,
private authService: AuthService,
private dialog: MatDialog,
public bottomSheet: MatBottomSheet,
private changeDetectionRef: ChangeDetectorRef,
) {
this.user$ = this.authService.user$
......@@ -60,6 +72,11 @@ export class SigninBanner {
}
}
disableScreenshotTaking() {
this.takingScreenshot = false
this.changeDetectionRef.detectChanges()
}
private keyListenerConfigBase = {
type: 'keydown',
stop: true,
......
......@@ -51,7 +51,7 @@
<mat-menu #pluginDropdownMenu>
<button mat-menu-item
[disabled]="!parcellationIsSelected"
(click)="takeScreenshotElement.startScreenshot()"
(click)="takingScreenshot = true;"
[matTooltip]="screenshotTooltipText">
<mat-icon fontSet="fas" fontIcon="fa-camera">
</mat-icon>
......@@ -126,15 +126,15 @@
</mat-dialog-actions>
</ng-template>
<ng-template #settingTemplate>
<h2 mat-dialog-title>Settings</h2>
<mat-dialog-content>
<!-- required to avoid showing an ugly vertical scroll bar -->
<!-- TODO investigate why, then remove the friller class -->
<config-component class="mb-4 d-block">
</config-component>
</mat-dialog-content>
</ng-template>
<ng-template #settingTemplate>
<h2 mat-dialog-title>Settings</h2>
<mat-dialog-content>
<!-- required to avoid showing an ugly vertical scroll bar -->
<!-- TODO investigate why, then remove the friller class -->
<config-component class="mb-4 d-block">
</config-component>
</mat-dialog-content>
</ng-template>
<!-- saved dataset tmpl -->
......@@ -172,5 +172,8 @@
<take-screenshot
#takeScreenshotElement
class="position-fixed fixed-top">
*ngIf="takingScreenshot"
class="position-fixed fixed-top"
(screenshotTaking)="disableScreenshotTaking()"
(resetScreenshot)="$event? takingScreenshot = true : disableScreenshotTaking()">
</take-screenshot>
import {DOCUMENT} from "@angular/common";
import {
ChangeDetectorRef,
Component,
ElementRef,
HostListener,
Inject,
OnInit,
Renderer2,
TemplateRef,
ViewChild,
ChangeDetectorRef,
Component,
ElementRef, EventEmitter,
HostListener,
Inject, OnDestroy,
OnInit, Output,
Renderer2,
TemplateRef,
ViewChild,
} from "@angular/core";
import {MatDialog, MatDialogRef} from "@angular/material/dialog";
import html2canvas from "html2canvas";
......@@ -19,11 +19,21 @@ import html2canvas from "html2canvas";
styleUrls: ['./takeScreenshot.style.css'],
})
export class TakeScreenshotComponent implements OnInit {
export class TakeScreenshotComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {
if (this.resettingScreenshotTaking) this.resetScreenshot.emit(true)
this.resettingScreenshotTaking = false
}
@ViewChild('screenshotPreviewCard', {read: ElementRef}) public screenshotPreviewCard: ElementRef
@ViewChild('previewImageDialog', {read: TemplateRef}) public previewImageDialogTemplateRef: TemplateRef<any>
@Output() screenshotTaking: EventEmitter<boolean> = new EventEmitter<boolean>()
@Output() resetScreenshot: EventEmitter<boolean> = new EventEmitter<boolean>()
private resettingScreenshotTaking: boolean = false
private dialogRef: MatDialogRef<any>
public takingScreenshot: boolean = false
......@@ -67,6 +77,9 @@ export class TakeScreenshotComponent implements OnInit {
public ngOnInit(): void {
this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
this.startScreenshot()
}
@HostListener('window:resize', ['$event'])
......@@ -201,6 +214,7 @@ export class TakeScreenshotComponent implements OnInit {
.then(result => {
switch (result) {
case 'again': {
this.restartScreenshot()
this.startScreenshot()
this.cdr.markForCheck()
break
......@@ -241,12 +255,15 @@ export class TakeScreenshotComponent implements OnInit {
})
}
public restartScreenshot() {
this.resettingScreenshotTaking = true
this.resetScreenshot.emit(false)
}
public cancelTakingScreenshot() {
this.takingScreenshot = false
this.previewingScreenshot = false
this.loadingScreenshot = false
this.croppedCanvas = null
this.screenshotTaking.emit(false)
}
public clearStateAfterScreenshot() {
this.mouseIsDown = false
this.isDragging = false
......
<div class="screenshotContainer overflow-hidden w-100 h-100"
<div class="screenshotContainer overflow-hidden w-50 h-50"
(mousemove)="move($event)"
(mousedown)="mouseDown($event)"
(mouseup)="mouseUp($event)"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment