Team:Cornell/sandbox

From 2013.igem.org

(Difference between revisions)
Line 310: Line 310:
----------------------------------------- */
----------------------------------------- */
.section {         
.section {         
-
width:540px; height:500px;
+
-
                  background:url("https://static.igem.org/mediawiki/igem.org/6/67/IGEMsmall.png") no-repeat #000;
+
}
}
.section .inner {  
.section .inner {  
-
width:540px; height:500px;
+
-
                  background:url("http://hotdot.pro/static/img/mainPage/intro/4.png") no-repeat;
+
}
}
</style>
</style>
<script type="text/javascript">
<script type="text/javascript">
-
// The plugin code
+
-
(function($){
+
-
    $.fn.parallax = function(options){
+
-
        var $$ = $(this);
+
-
        offset = $$.offset();
+
-
        var defaults = {
+
-
            "start": 0,
+
-
            "stop": offset.top + $$.height(),
+
-
            "coeff": 0.95
+
-
        };
+
-
        var opts = $.extend(defaults, options);
+
-
        return this.each(function(){
+
-
            $(window).bind('scroll', function() {
+
-
                windowTop = $(window).scrollTop();
+
-
                if((windowTop >= opts.start) && (windowTop <= opts.stop)) {
+
-
                    newCoord = windowTop * opts.coeff;
+
-
                    $$.css({
+
-
                        "background-position": "0 "+ newCoord + "px"
+
-
                    });
+
-
                }
+
-
            });
+
-
        });
+
-
    };
+
-
})(jQuery);
+
-
 
+
-
// call the plugin
+
-
$('.section').parallax({ "coeff":-0.65 });
+
-
$('.section .inner').parallax({ "coeff":1.15 });
+
</script>
</script>
</head>
</head>

Revision as of 03:05, 24 December 2013

Parallax Test

Whee