Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(window).load(function(){
- // Load the first images visible in view-port.
- jQuery(".work .project .images img:in-viewport").each(function() {
- loadImage(jQuery(this));
- });
- });
- jQuery(document).ready(function(){
- /* Cache Elements for Use */
- var images = jQuery(".work .project .images");
- /* Catch the main scroll event */
- jQuery(window).scroll(function (e) {
- var scrollTop = jQuery(this).scrollTop();
- /*=======================
- Image Loading
- =======================*/
- loadImage( images.find("img:right-of-screen:first") );
- if (jQuery(window).width() < 1100) {
- jQuery(".work .images .image img:right-of-screen").each(function(){
- loadImage( jQuery(this) );
- });
- }
- });
- });
- /* Loads and fades in image */
- function loadImage(image, callback) {
- if (typeof callback == 'undefined') { callback = function(){}; }
- if (image.attr("src") == "images/core/transparent.gif") {
- image.animate({opacity:0}, 50, function() {
- image.attr("src", image.attr("data-original")).bind('load', function(){
- image.animate({opacity:1}, 1000).css({height:'auto'});
- callback();
- });
- });
- }
- }
- /*
- * Viewport - jQuery selectors for finding elements in viewport
- *
- * Copyright (c) 2008-2009 Mika Tuupola
- *
- * Licensed under the MIT license:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * Project home:
- * http://www.appelsiini.net/projects/viewport
- *
- */
- (function($){$.belowthefold=function(element,settings){var fold=$(window).height()+$(window).scrollTop();return fold<=$(element).offset().top-settings.threshold;};$.abovethetop=function(element,settings){var top=$(window).scrollTop();return top>=$(element).offset().top+$(element).height()-settings.threshold;};$.rightofscreen=function(element,settings){var fold=$(window).width()+$(window).scrollLeft();return fold<=$(element).offset().left-settings.threshold;};$.leftofscreen=function(element,settings){var left=$(window).scrollLeft();return left>=$(element).offset().left+$(element).width()-settings.threshold;};$.inviewport=function(element,settings){return!$.rightofscreen(element,settings)&&!$.leftofscreen(element,settings)&&!$.belowthefold(element,settings)&&!$.abovethetop(element,settings);};$.extend($.expr[':'],{"below-the-fold":function(a,i,m){return $.belowthefold(a,{threshold:-200});},"above-the-top":function(a,i,m){return $.abovethetop(a,{threshold:0});},"left-of-screen":function(a,i,m){return $.leftofscreen(a,{threshold:0});},"right-of-screen":function(a,i,m){return $.rightofscreen(a,{threshold:0});},"in-viewport":function(a,i,m){return $.inviewport(a,{threshold:150});}});})(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement