Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:48:59+00:00 2026-06-08T21:48:59+00:00

Is there a way in javascript to bind an event handler to a horizontal

  • 0

Is there a way in javascript to bind an event handler to a horizontal scroll as opposed to the generic scroll event which is fired when the user scrolls horizontally and vertically? I want to trigger an event only when the user scrolls horizontally.

I searched around for an answer to this question, but couldn’t seem to find anything.

Thanks!

P.S. My apologies if I’m using some terminology incorrectly. I’m fairly new to javascript.

UPDATE

Thanks so much for all your answers! In summary, it looks like you are all saying that this isn’t supported in javascript, but I that I can accomplish the functionality with something like this (using jQuery) (jsFiddle):

var oldScrollTop = $(window).scrollTop();

$(window).bind('scroll', function () {
    if (oldScrollTop == $(window).scrollTop())
        //scrolled horizontally
    else {
        //scrolled vertically
        oldScrollTop = $(window).scrollTop();
    }
});​

That’s all I needed to know. Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:49:01+00:00Added an answer on June 8, 2026 at 9:49 pm

    Answering from my phone, so unable to provide code at the moment.

    What you’ll need to do is subscribe to the scroll event. There isn’t a specific one for vertical/horizontal.

    Next, you’ll need to get some measurements about the current display area. You’ll need to measure the window.clientHeight and window.clientWidth.

    Next, get window.top and window.left. This will tell you where position of the viewport is, ie if it’s greater than 0 then scroll bars have been used.

    It’s pretty simple math from here to get what you need. If no one else has provided a code example in the next few hours I’ll try to do so.

    Edit:
    A bit further information.

    You must capture the scroll event. You also need to store the initial window.top and window.left properties somewhere. Whenever the scroll event happens, do a simple check to see if the current top/left values differ from the stores value.

    At this point, if either are different you can trigger your own custom events to indicate vertical or horizontal scrolling. If you are using jQuery, this is very easy. If you are writing js without library assistance, it’s easy too but a little more involved.

    Do some searches for event dispatching in js.

    You can then write any other code you want to subscribe to your custom events without needing to tie them together with method calls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to add an event listener/handler to a JavaScript object? Preferably
Is there any way to bind a mouse event such as 'mouseover' to a
I have written one JavaScript function which would rise the event when the User
Is there a way in JavaScript to select a element of a multidimential array.
Is there a way in JavaScript or jQuery to call a function when the
Is there a way in JavaScript to compare values from one array and see
is there a way with javascript/jquery to prevent images from loading? I am building
Is there a way in JavaScript for me to tell whether a resource is
Is there no way for javascript hosted on a webserver to read a file
Is there a JavaScript way to store data that is unique to a browser

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.