Jump to content


Horizontal scrolling with GSAP and ScrollMagic on tablets

Recommended Posts

Hi! Not sure if this is the best place to ask help regarding this, but this forum was very helpful to get me started with gsap and scrollmagic.


I'm currently working on a horizontal scrolling website with ScrollMagic and GSAP. I've stumbled upon several examples and it's working well on desktops with mousewheel function. However, when it comes to tablets where mousewheel is not applicable, the anchor navigations don't work and the results when using Chrome and Safari varies (anchor links not working on ipad chrome but works well on ipad safari). I added a drag function which is helpful for tablets, but it staggers and the animation is not very smooth.


Below is the mousewheel function I used:


document.addEventListener('wheel', function(e){
    if(e.type != 'wheel'){
    let delta = ((e.deltaY || -e.wheelDelta || e.detail) >> 1) || 1;
    document.documentElement.scrollLeft += delta;
    document.body.scrollLeft += delta;


And here is the drag function where I based from 

See the Pen VwYeYEE by thenutz (@thenutz) on CodePen


const slider = document.querySelector('html');
let isDown = false;
let startX;
let scrollLeft;

slider.addEventListener('mousedown', (e) => {
    isDown = true;
    startX = e.pageX - slider.offsetLeft;
    scrollLeft = slider.scrollLeft;
slider.addEventListener('mouseleave', () => {
    isDown = false;
slider.addEventListener('mouseup', () => {
    isDown = false;
slider.addEventListener('mousemove', (e) => {
    if(!isDown) return;
    const x = e.pageX - slider.offsetLeft;
    const walk = (x - startX) * 3;
    slider.scrollLeft = scrollLeft - walk;

Unfortunately, with recent ipad update, it seems not possible to detect if the user is using an ipad or ipad pro.

Is there something wrong with the code or possibly css that can fix this? Appreciate any help!

See the Pen JjEyjgb by shirasaki (@shirasaki) on CodePen

Link to comment
Share on other sites

Hi @false_hero


ScrollMagic is not a GreenSock product and not supported here. Have you seen GreenSock's ScrollTrigger plugin?

If you have specific GSAP related questions or problems, we're happy to help, but we don't have the resources to assist with 3rd party plugins and general logic issues.


Let us know if you have a GSAP question and best of luck with your project.


Happy tweening.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.