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

109
Visualizações
Avoid lag when scaling image

I have this problem, my image is very lagy when i'm scaling it using the transform: scale(); property in CSS. I'm scaling the picture from 0 to 1.

My picture is downsize by a lot so I don't think the problem could come from here.

Here's a video of the actual problem : lag image video

Here is the HTML :

<div class="picture-container first-part">
          <div
            class="picture-frame first-part"
            :style="{
              width: pictureFrameWidth + '%',
              height: pictureFrameHeight + 'vh',
            }"
          >
            <img
              src="../assets/pictures/cathedrale.jpg"
              alt="picture of Notre Dame de Reims"
              class="picture top-left"
              id="firstPic"
              :style="{ transform: 'scale(' + pictureScale + ')' }"
            />
          </div>
        </div>

CSS:

.picture-container {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  justify-self: center;
  align-items: center;

  width: 40%;
  height: 100vh;
}
.picture-container.first-part {
  position: sticky;

  top: 0px;
}
.picture-frame {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  align-items: center;

  padding: 5%;

  border: solid 1px var(--color);
}
.picture {
  z-index: 1;
  width: 100%;
  height: 100%;
}

JS :

constrain(n, high, low) {
      return Math.max(Math.min(n, high), low);
    },
resizePicture() {
  this.pictureScale = window.scrollY / 1500 - 0.75;
      let constrainedPictureScale = this.constrain(this.pictureScale, 1, 0);
      this.pictureScale = constrainedPictureScale;
}

I'm calling the resizePicture() function when the user scroll.

So if you have any idea of how I could optimize this or do it in a different way, I just don't want this lag.

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