Skip to content

Instantly share code, notes, and snippets.

View sdaityari's full-sized avatar

Shaumik Daityari sdaityari

View GitHub Profile

Create Parallax Scrolling using jQuery

Parallax scrolling is a relatively new trend in web design. With this effect, you can create an illusion of depth on your webpage. Parallax works by making the background of the webpage scroll at a slower speed that the foreground, thus giving the scene a perceived depth. This is similar to the idea that when you are moving, objects nearer to you move at slower speeds- hence, the background appears to be behind the foreground.

So, how do we achieve this effect? Well, it's quite simple really. Whenever a users scrolls on the page, we calculate how much the page has been scrolled. We then scale down this scroll-height and move the background image up or down accordingly. Here's the result we wish to achieve.

Parallax1

Don't worry though, this is just a gif image. The actual result is completely smooth. Let's get st

@sdaityari
sdaityari / heart.xml
Created October 31, 2012 18:43
Heart Bookmarking Gadget
<!-- Start Heart Bookmarking Gadget Code From http://www.spiceupyourblog.com/ -->
<script src='http://w.sharethis.com/gallery/shareegg/shareegg.js' type='text/javascript'/>
<script src='http://w.sharethis.com/button/buttons.js' type='text/javascript'/>
<script type='text/javascript'>stLight.options({publisher: &quot;ur-98d377f-bdd3-9ad1-fbe5-2a678f0a60ee&quot;, onhover:false}); </script>
<link href='http://w.sharethis.com/gallery/shareegg/shareegg.css' media='screen' rel='stylesheet' type='text/css'/>
<!-- End Heart Bookmarking Gadget Code From http://www.spiceupyourblog.com/ -->
@sdaityari
sdaityari / shaumik_fb_like.html
Created October 31, 2012 18:23
Facebook like for Transcendental Tech Talk
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=243423985670705";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="https://www.facebook.com/shaumikthinks" data-send="true" data-layout="button_count" data-width="180" data-show-faces="true" data-colorscheme="light"></div>
@sdaityari
sdaityari / fb_like.html
Created October 31, 2012 18:25
Facebook like for Transcendental Tech Talk
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=243423985670705";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- IMPORTANT change the link, width, and colorscheme accordingly below -->
@sdaityari
sdaityari / title.xml
Created October 31, 2012 18:37
Blog Title
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<title><data:blog.title/></title>
<b:else/>
<title><data:blog.pageName/> | <data:blog.title/></title>
</b:if>
@sdaityari
sdaityari / like.xml
Created October 31, 2012 18:51
Like button and Like Box
<!-- FB LIKE Button -->
<!-- add a facebook App ID -->
<iframe allowTransparency='true' expr:src='&quot;//www.facebook.com/plugins/like.php?href=&quot; + data:post.url + &quot;&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80&amp;appId=<your_app_id>&quot;' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:450px; height:28px;'/>
<!-- LIKE ends -->
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<b:else/>
<!-- FB LIKE box -->
<!-- change the href below with the link of your blog's Fb page -->
<iframe allowTransparency='true' frameborder='0' scrolling='no' src='//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fshaumikthinks&amp;width=600&amp;height=590&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=true&amp;header=true&amp;appId=243423985670705' style='border:none; overflow:hidden; width:550px; height:590px;'/>
@sdaityari
sdaityari / heart1.xml
Created October 31, 2012 18:46
Heart Bookmarking Gadget
<!-- Start Heart Share Code From http://www.spiceupyourblog.com/ -->
<div style='position: fixed; bottom: 2%; left: 2%;'>
<div class='shareEgg' id='shareThisShareHeart'/>
</div>
<script type='text/javascript'>stlib.shareEgg.createEgg(&#39;shareThisShareHeart&#39;, [&#39;facebook&#39;,&#39;twitter&#39;,&#39;pinterest&#39;,&#39;linkedin&#39;,&#39;stumbleupon&#39;,&#39;email&#39;,&#39;sharethis&#39;], {title:&#39; <data:blog.pageTitle/>&#39;,url:&#39;<data:blog.url/>&#39;,theme:&#39;shareheart&#39;});</script><a href="http://www.spiceupyourblog.com/">Blogger Wordpress Gadgets</a>
<!-- End Heart Share Code From http://www.spiceupyourblog.com/ -->
@sdaityari
sdaityari / index.html
Created September 14, 2018 21:26
blocks.org test
<!DOCTYPE html>
<html>
<head>
<title>The d3 test</title>
<style>
.axis line, .axis path {
stroke: black;
fill: none;
}
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>