통합검색

Javascript

[Jquery] 숫자 효과

  • 2022.10.28 09:36:34
[!]jQuery[/!]
 
<script type="text/javascript">
$(function(){
    var loop = 0
    $(window).on({
        'scroll load' : function(){
            var st = parseInt($(window).scrollTop());
            var pos = $('._counter').offset().top - ($(window).height() / 2);
            if(st >= pos && loop==0){
                $("._counter strong").each(function(i){
                    $(this).flipping_text({
                        tickerTime: 30,
                        tickerCount: 15,
                        customRandomChar: "1234567890"
                    });
                })
                loop++;
            }
        }
    })

})
</script>




/* jQuery Plugin : counter number */
!function(e){function r(e,t){var n,r,i=t;this.pause=function(){window.clearTimeout(n);i-=new Date-r};this.resume=function(){r=new Date;n=window.setTimeout(e,i)};this.resume()}var t={tickerTime:10,customRandomChar:false,tickerCount:10,opacityEffect:true,resetOnChange:false};var n=false;e.fn.flipping_text=function(i){var s=this;resetAll=function(t){t.each(function(t){e(this).css({opacity:1,visibility:"visible"}).text(e(this).data("ft-text"))})};return this.each(function(o){function c(){var e=f.text(),t=0;if(a.customRandomChar!=false){var i=a.customRandomChar}else{var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}f.attr("data-ft-text",e).html("");for(var s=0;s<l;s++){f.append("<span data-ft-bk='"+e.charAt(s)+"' class='ft_char"+s+"'></span>");var o=new r(function(){t=t+1;var e=0;if(n==true){return false}else{for(var s=0;s<a.tickerCount;s++){var o=f.find(".ft_char"+(t-1));var u=new r(function(){if(n==true){return false}else{if(e==a.tickerCount-2){o.css("opacity","1").text(o.data("ft-bk"));return false}else{if(a.opacityEffect==true){var t=e/a.tickerCount}else{var t=1}o.css("opacity",t).text(i.charAt(Math.floor(Math.random()*i.length)));e++}}},s*a.tickerTime)}}},(s+1)*a.tickerTime*a.tickerCount)}}if(e(this).data("delay")!==undefined){var u=e(this).data("delay")+0}else{var u=0}var a=e.extend({},t,i),f=e(this),l=f.text().length;if(a.resetOnChange==true){e(window).on("blur",function(){n=true;resetAll(s)})}f.css("visibility","hidden");var h=new r(function(){if(n==true){return false}else{f.css("visibility","visible");c()}},u*o)})}}(window.jQuery)