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

281
Visualizações
How to disable a sticky element on smartphones using locomotive library?

I have a question regarding javascript.(I'm new). I'm using the locomotive smooth scroll library in a Webflow project. Because Webflow interactions tend to not work very well in combination with locomotive, I've used the functionality provided by locomotive to create a sticky element. On mobile I want to disable the sticky effect. This is the locomotive code:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/locomotive-scroll@3.5.4/dist/locomotive-scroll.css">
<script src="https://cdn.jsdelivr.net/npm/locomotive-scroll@4.1.1/dist/locomotive-scroll.min.js"></script>
<script>
const locoScroll = new LocomotiveScroll({
  el: document.querySelector(".locomotive-scroll"),
  smooth: true,
  smartphone: {
      smooth: true
  },
  tablet: {
      smooth: true
  },
    smoothMobile: 1,
  multiplier: 1.0,
}); 
</script>

The parent div of the sticky element has an ID assigned called #sticky1 The div that sticks to the top of the viewport has the following attributes: attributes

How do I make it so that on mobile, the sticky effect is removed? Hope my question makes sense!

Kind regards, Jeroen

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

0

You can simply use javascript to remove the data-scroll-sticky attribute from your div BEFORE you initialize locomotive for example:

if(isMobile) {
      element.removeAttribute(data-scroll-sticky);
      element.removeAttribute(data-scroll-target);
}

const locoScroll = new LocomotiveScroll({
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