Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
Close gallery when click outside element- JavaScript/Angular

  openModalAttachment(template: TemplateRef<any>, index: number) {
    this.index = index;
    this.getFile(index);
    this.modalRef = this.modalService.show(template);
    this.openModalAnexo = true;
    this.fullScreen();
  }

  onClick(event) {
    event.stopPropagation();
    var modalAnexo = document.getElementById('imgAnexo');
    console.log(this.openModalAnexo, modalAnexo);
    if (this.openModalAnexo && !modalAnexo) {
      console.log(event.target);

      this.openModalAnexo = false;
      modalAnexo = null;
      this.closeFullScreen();
    }
  }
  onCloseAttachment() {
    this.message = 'Declined!';
    this.index = -1;
    this.modalRef?.hide();
    this.closeFullScreen();
  }
  closeFullScreen() {
    
    document.onclick = function (event) {
      if (document.fullscreenElement) {
        event.stopPropagation();
        document
          .exitFullscreen()
          .then(() => console.log('Document Exited from Full screen mode'))
          .catch((err) => console.error(err));
      }
      
    };
  }
  fullScreen() {
    if (!document.fullscreenElement) {
      document.documentElement.requestFullscreen();
      
    }
  }
 <img src="/assets/icons/eysblue.svg" class="openAtchament" (click)="openModalAttachment(attachment, j)"
                *ngIf="collapseData.label == 'ANEXOS'">

<ng-template #attachment >
  <div class="" id="myModal">
    <div class="modal-content">
      <div class="modalOpenGaley">
        <span class="close" (click)="onCloseAttachment().document.getElementById('lightbox')">&times;</span>
        <embed [src]="file" #files id="imgAnexo" class="files-images-pdf"
        type="application/pdf">
        <img [src]="file" id="imgAnexo" class="files-images-pdf" />
        <div id="caption"></div>
      </div>
    </div>
    </div>
</ng-template>

I've done a lot of research and I haven't found anything, I'm quite a layman, please help me. when opening my image it needs to be opened in fullscreen, when i click out of the image to close the image there is a bug of not going out in fullscreen mode.

clicking away is fullscren like this: enter image description here

the correct one would be: when clicking outside the image, close the fullscreen and look like this:

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda