Prevent Horizontal Scroll on Pages with Jquery.mousewheel.js

Javascript coding ..

Moderators: macek, egami, gesf

koalaelf
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Oct 17, 2013 1:33 pm

Prevent Horizontal Scroll on Pages with Jquery.mousewheel.js

Postby koalaelf » Thu Oct 17, 2013 7:57 pm

Ok so I've managed to get horizontal scroll via mousewheel working on my wordpress site (with Expositio theme) using jquery.mousewheel.js plugin

(you can find it here if you are struggling like I did with broken links all over the place!) https://github.com/brandonaaron/jquery- ... ll/master/

After this code in the header.php ...

Code: Select all

      <?php
         wp_enqueue_script( 'jquery' );
         
         if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
         wp_head();
      ?>


...I've inserted this :

Code: Select all

      
<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/includes/jquery.mousewheel.js"></script>

<script type="text/javascript">
   jQuery(function($) {
      $('html, body').mousewheel(function(event, delta) {
         this.scrollLeft -= (delta * 90);
         event.preventDefault();
      })
   });
</script>


Which works well.

However, I would like to prevent this javascript from loading on certain pages (since pages don't have the horizontal layout that posts do in this theme)

In other words, I want most of the site to scroll horizontally with the mousewheel (as I currently have it), but be able to specify either individual pages (eg: 'About', 'Contact' etc) or maybe even just 'all' pages; where the mousewheel will behave normally (ie. scrolling vertically)

Any help would be much appreciated, since I have very little knowledge of these things.
:oops:

Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest