2017-05-20 7 views
0

Wie setze ich Count up nicht automatisch laufen? ich möchte, dass bis machen zählen nur starten, wenn ich auf das ScrollenCount Up Start automatisch

HTML-Code:

<!-- COUNT UP --> 
    <div id="countup" class="countup parallax-window" data-parallax="scroll" data-image-src="img/basic/background-count.jpg"><!-- start countup div--> 
     <div class="container"> 
      <div class="row"> 

       <h2>The <b>Count</b></h2> 
       <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
       <br>Lorem Ipsum has been the industry's standard</p> 

       <div class="col-sm-3 col-md-3"> 
        <i class="fa fa-pencil-square-o" aria-hidden="true"></i> 
        <h3 class="counter" data-count="350">0</h3> 
        <h4>Project</h4> 
       </div> 

       <div class="col-sm-3 col-md-3"> 
        <i class="fa fa-coffee" aria-hidden="true"></i> 
        <h3 class="counter" data-count="755">0</h3> 
        <h4>Coffee</h4> 
       </div> 

       <div class="col-sm-3 col-md-3"> 
        <i class="fa fa-thumbs-up" aria-hidden="true"></i> 
        <h3 class="counter" data-count="2500">0</h3> 
        <h4>Smile</h4> 
       </div> 

       <div class="col-sm-3 col-md-3"> 
        <i class="fa fa-users"></i> 
        <h3 class="counter" data-count="50">0</h3> 
        <h4>Employee</h4> 
       </div> 

      </div> 
     </div> 
    </div> 
    <!-- END COUNT UP --> 

Javascript-Code: `

$('.counter').each(function() { 
    var $this = $(this), 
     countTo = $this.attr('data-count'); 

    $({ countNum: $this.text()}).animate({ 
    countNum: countTo 
    }, 

    { 

    duration: 5000, 
    easing:'linear', 
    step: function() { 
     $this.text(Math.floor(this.countNum)); 
    }, 
    complete: function() { 
     $this.text(this.countNum); 
     //alert('finished'); 
    } 
    }); 
}); 

Und die ss: enter image description here

Antwort

0

$('.counter').hover(
 
function(){ 
 
var $this = $(this), 
 
     countTo = $this.attr('data-count'); 
 

 
    $({ countNum: $this.text()}).animate({ 
 
    countNum: countTo 
 
    }, 
 

 
    { 
 

 
    duration: 5000, 
 
    easing:'linear', 
 
    step: function() { 
 
     $this.text(Math.ceil(this.countNum)); 
 
    }, 
 
    complete: function() { 
 
     $this.text(this.countNum); 
 
     //alert('finished'); 
 
    } 
 
    }); 
 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="countup" class="countup parallax-window" data-parallax="scroll" data-image-src="img/basic/background-count.jpg"><!-- start countup div--> 
 
     <div class="container"> 
 
      <div class="row"> 
 

 
       <h2>The <b>Count</b></h2> 
 
       <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
 
       <br>Lorem Ipsum has been the industry's standard</p> 
 

 
       <div class="col-sm-3 col-md-3"> 
 
        <i class="fa fa-pencil-square-o" aria-hidden="true"></i> 
 
        <h3 class="counter" data-count="350">0</h3> 
 
        <h4>Project</h4> 
 
       </div> 
 

 
       <div class="col-sm-3 col-md-3"> 
 
        <i class="fa fa-coffee" aria-hidden="true"></i> 
 
        <h3 class="counter" data-count="755">0</h3> 
 
        <h4>Coffee</h4> 
 
       </div> 
 

 
       <div class="col-sm-3 col-md-3"> 
 
        <i class="fa fa-thumbs-up" aria-hidden="true"></i> 
 
        <h3 class="counter" data-count="2500">0</h3> 
 
        <h4>Smile</h4> 
 
       </div> 
 

 
       <div class="col-sm-3 col-md-3"> 
 
        <i class="fa fa-users"></i> 
 
        <h3 class="counter" data-count="50">0</h3> 
 
        <h4>Employee</h4> 
 
       </div> 
 

 
      </div> 
 
     </div> 
 
    </div>

testen

+0

Dank für Hilfe mich aber, dass nur starten, wenn ich es richtig schweben? Tun Sie eine andere Lösung? I machen möchte es starten, wenn ich auf sie bewegen – Zuhri

+0

@Zuhri leid Ich habe Sie nicht bekommen – Durga

+0

Dies ist das Beispiel meines Web http://upto.esy.es/ überprüfen Sie den unteren Rand der Seite, die Zählung beginnt von selbst zu zählen (automatisch) und ich kann nicht sehen, die Animate haben Sie eine Seelenverfassung wie man es repariert? – Zuhri

Verwandte Themen