Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

ian izaguirre
ian izaguirre
3,220 Points

How does this rock band website have this type of scroll effect?

Hi, I wanted to know how I can do something like http://www.blacksabbath.com/ does.... when you move your mouse to the right the page continues ( its not a slider? ) so its just like one short but really large width page ? How is this done and how can I recreate it , is it difficult ?

10 Answers

Michael Wiss
Michael Wiss
19,233 Points

They're using http://www.smoothdivscroll.com/. One of my favorite ways to learn about web development is to deconstruct the code. If you've got Chrome you can access the dev tools with command-option-i and check out the sources panel or just view source it. Firebug for firefox is similar.

ian izaguirre
ian izaguirre
3,220 Points

Thank you so much for your help. Quick question, I connected a JS file , and on this page : http://www.smoothdivscroll.com/download.html , I downloaded that file ...... BUT I have wordpress. So how do I upload these files , manually? since its not a wordpress plugin

ian izaguirre
ian izaguirre
3,220 Points

So I can include a non wordpress plugin like smooth scrolling then, its possible ??? and if its is possible then I just enqueue the Java script files in my functions right ? I don't need to enqueue other files ?

and looking at this : http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts

So where do I put the files of this plugin , do I just drag and drop them in FTP in my plugins folder even though they are not by default a wordpress plugin ?

Michael Wiss
Michael Wiss
19,233 Points

yeah, you can enqueue as many non wordpress scripts as you need. just make sure to include them in your js file.

ian izaguirre
ian izaguirre
3,220 Points

Ok so looking at the download from smooth scroll I see there is like 12 JS files in there. Before this plugin I already added a custom JS file on my site to add my own JS and I just went to functions and added this for that file called myscript.js and it worked :

          function theme_javascript()
          {
          // wp_enqueue_script( 'name', path, array( 'dependencies' ), version, in-    footer );
          wp_enqueue_script( 'myscript', get_template_directory_uri   () . '/js/myscript.js', array('jquery'), '20140109', true );
          }

      add_action( 'wp_enqueue_scripts', 'theme_javascript' );```

So I am not sure how to do it properly to connect these 12 JS files ?

Michael Wiss
Michael Wiss
19,233 Points

Plugins often have dependencies, just make sure you enqueue everything needed:

http://www.smoothdivscroll.com/dependencies.html

so I would also enqueue jquery ui, mousewheel, kinetic, and smoothDivscroll.

ian izaguirre
ian izaguirre
3,220 Points

ok so stuff like <script src="js/jquery.kinetic.js" type="text/javascript"></script> I put that in my functions ? or do I put all that code in a JS file ?

Michael Wiss
Michael Wiss
19,233 Points

Just enqeue them seperately following the same pattern you followed in your functions file

ian izaguirre
ian izaguirre
3,220 Points

Ok I will do that , with the 12 JS files but where do I include those different lines of script sources "dependencies"

Michael Wiss
Michael Wiss
19,233 Points

just jquery ui, mousewheel, kinetic, and smoothDivscroll in functions.php

ian izaguirre
ian izaguirre
3,220 Points

Ok so for example one of the files in the plugin is called jquery.kinetic.js

so is this all I put in my functions for this one file for example , is it written right like this :

 function theme_javascript()
 {
 wp_enqueue_script( 'jquery.kinetic', get_template_directory_uri  () . '/js/jquery.kinetic.js', array('jquery'), '20140109', true );
  }

add_action( 'wp_enqueue_scripts', 'theme_javascript' );
ian izaguirre
ian izaguirre
3,220 Points

Why does this not work ( its gives me a white screen so something's wrong with the code? )

 function theme_javascript()
 {
 wp_enqueue_script( 'kinetic', get_template_directory_uri() . '/js/kinetic.js', array('jquery'), '20140109', true );
 }

add_action( 'wp_enqueue_scripts', 'theme_javascript' );
ian izaguirre
ian izaguirre
3,220 Points

All of my effort has seen no affect so far, the website I am trying it on is Izzy.me ( you can see the pictures of the birds as a test )

The following is what I have in my functions just trying to connect the kinetic min js file first as a test , but its not working. These are all the combinations but with no luck :

 <?php


 // this is the code to connect your custom izzy java script file called myscript

 function theme_javascript()
 {
   // wp_enqueue_script( 'name', path, array( 'dependencies' ), version, in-footer );
   wp_enqueue_script( 'myscript', get_template_directory_uri() . '/js/myscript.js', array('jquery'), '20140109', true );
   wp_enqueue_script( 'kinetic', get_template_directory_uri() . '/js/jquery.kinetic.min.js', array('jquery'), '20140109', true );    
 }

 add_action( 'wp_enqueue_scripts', 'theme_javascript' );

 // this is another test 

 function my_init() {
     wp_enqueue_script('jquery');   
  }

   add_action('init', 'my_init');

  function my_scripts() {
  wp_enqueue_script(
     'kinetic',
     get_template_directory_uri() . '/js/jquery.kinetic.min.js',
     array( 'jquery' )
);
}

 add_action( 'get_footer', 'my_scripts' );


 ?>
Michael Wiss
Michael Wiss
19,233 Points

It won't work until you load all 4 of the scripts. The plugin Depends on the others to work. Just keep on tweaking, you'll get it to work.

Michael Wiss
Michael Wiss
19,233 Points

try registering the script:

ian izaguirre
ian izaguirre
3,220 Points

Thank you I will look into that. and No I have not gotten it to work I even made a thread on stack overflow but I still don't understand what I am doing wrong : http://stackoverflow.com/questions/21860055/trying-to-connect-smooth-div-scroll-jquery-to-my-site-but-its-not-connecting/21860337?noredirect=1#comment33112347_21860337