Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda