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

160
Views
Different type of position fixed but same result

I have code that it normally behaves but I want to implement momentum scroll. For the momentum scroll to work, I need to get the position fixed at the body tag. That is not a problem. The problem occurs in different elements with absolute positioning and flex grids.

Do you know a way that I can bypass the fixed positioning?

I am using the butter.js library for implementing momentum scroll but I tested with this codepen and it gives the same result

const body = document.body;
const main = document.getElementById('main');

let sx = 0, // For scroll positions
    sy = 0;
let dx = sx, // For container positions
    dy = sy;


body.style.height = main.clientHeight + 'px';


main.style.position = 'fixed';
main.style.top = 0;
main.style.left = 0;

// Bind a scroll function
window.addEventListener('scroll', easeScroll);


function easeScroll() {
  
  sx = window.pageXOffset;
  sy = window.pageYOffset;
}


window.requestAnimationFrame(render);

function render(){
  //We calculate our container position by linear interpolation method
  dx = li(dx,sx,0.07);
  dy = li(dy,sy,0.07);
  
  dx = Math.floor(dx * 100) / 100;
  dy = Math.floor(dy * 100) / 100;
  
  
  main.style.transform = `translate3d(-${dx}px, -${dy}px, 0px)`;
 
  
  
  window.requestAnimationFrame(render);
}

function li(a, b, n) {
  return (1 - n) * a + n * b;
}

Like I said it is not a problem with a code or the the way it is typed. I do not get error while handling it. But this

main.style.position = 'fixed';

is the problem. I do trying to connect to a body tag but it still same problem

Link to a codepen momentum scroll

this is an image that to show how does it mess up

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try changing the width of the 'main' element. They are usually coded to fit only elements not the screen

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!