Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!