Home > DeveloperSection > Forums > Horizontal scrolling Internal Anchor Links click with jquery
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    April-06-2013 1:43 AM

 JQuery JQuery 
Ratings:


 2 Reply(s)
 2066  View(s)
Rate this:
Hi!

I use jquery for horizontal scrolling with mousewheel.It is work ..

 $('html').mousewheel(function (event, delta) {
            this.scrollLeft += (delta * 50);
            event.preventDefault();
        });
I want horizontal scrolling Internal Anchor Links click,

I use this code :

   $(".prevscroll").click(function (event) {
               event.preventDefault();
               $.scrollTo(this.hash, 150, { easing: 'elasout' });
        });
or

  $(window).scrollLeft((Number($(window).scrollLeft()) + 50) + 'px');
or

 $('body').scrollLeft(50);
but don't scrolling !!!!

My html code

<script type='text/javascript' src="js/jquery.mousewheel.min.js"></script>
<script type='text/javascript' src="js/jquery.min.js"></script>
<script type='text/javascript' src="js/jquery.mousewheel.js"></script>
<style>
 .content
 {
padding: 20px 20px 0;
display: block;
z-index: 1;
height: 340px;
position: relative;
}
#contentWrapper
{
position: absolute;
max-width: 100%;
min-width: 400px;
min-height: 350px;
padding: 0 20px 30px 20px;
z-index: 1;
}
</style>


<div style="display: block;top:107px" id="contentWrapper">
  <a class="prevscroll"></a>
   <div style="margin-right: 0px;" id="content">
    //My content
   </div>
</div>


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    April-06-2013 8:28 AM

Hi Ankita!

Bind mousewheel function with body and replace -= to +=

$(function() {

    $("body").mousewheel(function(event, delta) {
        var $this = $(this);

        this.scrollLeft -= (delta) * 50;
        event.preventDefault();
    });
});

I hope it helpful you!


Vijay Shukla

Total Post:100

Points:700
Posted on    April-06-2013 9:22 AM

Hi!

You can try as following

$(".prevscroll").click(function (event) {
            $('html, body').scrollLeft($('html, body').scrollLeft()+150);
              event.preventDefault();
        });


Don't want to miss updates? Please click the below button!

Follow MindStick