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

268
Visualizações
medium-zoom implementation is not working in Angular 13

I am trying to implement medium-zoom from https://www.npmjs.com/package/medium-zoom

These are the steps I followed

  1. ng new medium_zoom_test (Angular 13) with routing & css
  2. npm install medium-zoom
  3. image is kept in assets

app.component.html

<h1>Zoom test</h1>
<img class="zoomy" width="50%" src="assets/image.svg">

app.component.ts

import { Component } from '@angular/core';
import mediumZoom from 'medium-zoom';

mediumZoom('.zoomy', {
  margin: 40,
  background: '#ffffff',
  scrollOffset: 40
})

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'medium_zoom_test';
}

On serving the application the webpage with image is visible. However, there's no zoom icon on hover and the image won't zoom on click. It's just a normal webpage with no change.

Any alternatives to implement the zooming of images are welcome too.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't think mediumZoom will work when the passed selector has no corresponding element in the DOM. What I mean is where you call mediumZoom function the component is not attached to the DOM yet. If you want to guarantee that you need to call it on ngOnInit lifecycle hook. Or you can do better which is to define a directive that applies the zoom affect like this :

import mediumZoom from 'medium-zoom';

@Directive({
  selector: '[appZoomie]'
})
export class ZoomieDirective {

  constructor(private el: ElementRef) {
    mediumZoom(el.nativeElement, {
      margin: 40,
      background: '#ffffff',
      scrollOffset: 40
    })
   }
}

And use it like this :

<img appZoomie src=".."/>

Stackblitz

about 4 years ago · Juan Pablo Isaza Relatório
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