Last active
August 29, 2015 14:04
-
-
Save dstyle0210/0e66d84e2a788d9f3c00 to your computer and use it in GitHub Desktop.
preloader 이미지 프리로더
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| jQuery.fn.extend({ | |
| preload:function(){ | |
| } | |
| }); | |
| preload: function(selector, parameters) { | |
| var params = { | |
| delay: 250, | |
| transition: 350, | |
| easing: 'linear' | |
| }; | |
| $j.extend(params, parameters); | |
| $j(selector).css({opacity: 0}); | |
| $j(selector).wrap('<span class="preloader" />'); | |
| $j(selector).one("load", function() { | |
| $j(this).delay(params.delay).animate({opacity: 1}, params.transition, params.easing, function(){ | |
| $j(this).unwrap('<span class="preloader" />'); | |
| }); | |
| }).each(function() { | |
| if(this.complete) $j(this).trigger("load"); | |
| }); | |
| }, | |
| document 로드후 사용. | |
| */ | |
| (function($){ | |
| $.fn.preload = function(arg){ | |
| var o = {delay:250,transition:350,easing:'linear'}; | |
| $.extend(o,arg); | |
| $(this).css({opacity:0}); | |
| $(this).wrap('<span class="preloader" />'); | |
| $(this).each(function(i,item){ | |
| $(item).parent().css({ | |
| display:"inline-block", | |
| width:$(item).width(), | |
| height:$(item).height(), | |
| background:"url('ajax-loader.gif') no-repeat center center" | |
| }); | |
| }); | |
| $(this).one("load",function(){ | |
| $(this).delay(o.delay).animate({opacity: 1}, o.transition, o.easing, function(){ | |
| $(this).unwrap('<span class="preloader" />'); | |
| }); | |
| }).each(function() { | |
| if(this.complete) $(this).trigger("load"); | |
| }); | |
| }; | |
| $.preload = function(arg){ | |
| var o = {delay:10000,transition:350,easing:'linear'}; | |
| $.extend(o,arg); | |
| var img = $(".preload"); | |
| $(img).css({opacity:0}); | |
| $(img).wrap('<span class="preloader" />'); | |
| $(img).each(function(i,item){ | |
| $(item).parent().css({ | |
| display:"inline-block", | |
| width:$(item).width(), | |
| height:$(item).height(), | |
| background:"url('ajax-loader.gif') no-repeat center center" | |
| }); | |
| }); | |
| $(img).one("load",function(){ | |
| $(this).delay(o.delay).animate({opacity: 1}, o.transition, o.easing, function(){ | |
| $(this).unwrap('<span class="preloader" />'); | |
| }); | |
| }).each(function() { | |
| if(this.complete) $(this).trigger("load"); | |
| }); | |
| } | |
| })(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment