Skip to content

Commit bc69d97

Browse files
Breno PrataBreno Prata
authored andcommitted
Iniciando o desenvolvimento para a versão 3.0
1 parent 5a15e56 commit bc69d97

File tree

3 files changed

+30
-803
lines changed

3 files changed

+30
-803
lines changed

src/image-viewer.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@
7272
<i class="material-icons prev" (click)="imagemAnterior()">keyboard_arrow_left</i>
7373
<i class="material-icons next" (click)="proximaImagem()">keyboard_arrow_right</i>
7474
<div class="footer-info">
75-
<span class="current"></span>/<span class="total"></span>
75+
<span id="current"></span>/<span class="total"></span>
7676
</div>
7777
</div>

src/image-viewer.component.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
import {AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, Renderer2, SimpleChanges} from '@angular/core';
1+
import {
2+
AfterViewInit,
3+
Component,
4+
EventEmitter,
5+
Input,
6+
OnChanges,
7+
OnInit,
8+
Output,
9+
Renderer2,
10+
SimpleChanges
11+
} from '@angular/core';
212

3-
declare var $: any;
413
declare var ImageViewer: any;
514

615
/**
@@ -18,9 +27,7 @@ export class ImageViewerComponent implements OnChanges, OnInit, AfterViewInit {
1827

1928
BASE_64_IMAGE = 'data:image/png;base64,';
2029
BASE_64_PNG = `${this.BASE_64_IMAGE} `;
21-
BASE_64_PDF = 'data:application/pdf;base64, ';
2230
ROTACAO_PADRAO_GRAUS = 90;
23-
TOTAL_ROTACAO_GRAUS_VERTICAL = this.ROTACAO_PADRAO_GRAUS * 3;
2431

2532
@Input() idContainer;
2633
@Input() images: any[];
@@ -61,7 +68,6 @@ export class ImageViewerComponent implements OnChanges, OnInit, AfterViewInit {
6168
rotacaoImagemAtual: number;
6269
stringDownloadImagem: string;
6370
isImagemVertical: boolean;
64-
mostrarPainelOpcoes = true;
6571
showOnlyPDF = false;
6672

6773
zoomPercent = 100;
@@ -158,13 +164,18 @@ export class ImageViewerComponent implements OnChanges, OnInit, AfterViewInit {
158164
}
159165

160166
inicializarImageViewer() {
167+
161168
this.indexImagemAtual = 1;
162-
this.totalImagens = this.images.length;
163-
this.wrapper = $(`#${this.idContainer}`);
164-
this.curSpan = this.wrapper.find('.current');
165-
this.viewer = ImageViewer(this.wrapper.find('.image-container'));
166-
this.wrapper.find('.total').html(this.totalImagens);
167169
this.rotacaoImagemAtual = 0;
170+
this.totalImagens = this.images.length;
171+
172+
this.wrapper = document.getElementById(`${this.idContainer}`);
173+
174+
if (this.wrapper) {
175+
this.curSpan = this.wrapper.querySelector('#current');
176+
this.viewer = new ImageViewer(this.wrapper.querySelector('.image-container'));
177+
this.wrapper.querySelector('.total').innerHTML = this.totalImagens;
178+
}
168179
}
169180

170181
showImage() {
@@ -183,7 +194,7 @@ export class ImageViewerComponent implements OnChanges, OnInit, AfterViewInit {
183194
this.stringDownloadImagem = this.BASE_64_IMAGE + this.getImagemAtual();
184195
}
185196
this.viewer.load(imgObj, imgObj);
186-
this.curSpan.html(this.indexImagemAtual);
197+
this.curSpan.innerHTML = this.indexImagemAtual;
187198
this.inicializarCores();
188199
}
189200

@@ -242,11 +253,14 @@ export class ImageViewerComponent implements OnChanges, OnInit, AfterViewInit {
242253
if (iframeElement) {
243254

244255
this.renderer.removeChild(container, iframeElement);
256+
257+
if (ivLargeImage) {
258+
259+
this.renderer.removeChild(container, ivLargeImage);
260+
}
245261
}
246262

247263
if (iframeElement) {
248-
249-
this.renderer.removeChild(container, ivLargeImage);
250264
}
251265

252266
this.setStyleClass('iv-loader', 'visibility', 'auto');
@@ -303,7 +317,7 @@ export class ImageViewerComponent implements OnChanges, OnInit, AfterViewInit {
303317
this.zoomPercent = 100;
304318
this.viewer.zoom(this.zoomPercent);
305319
let timeout = 800;
306-
if (this.viewer.zoomValue === this.zoomPercent) {
320+
if (this.viewer._state.zoomValue === this.zoomPercent) {
307321
timeout = 0;
308322
}
309323
return timeout;

0 commit comments

Comments
 (0)