Team:Bielefeld-CeBiTec/script.js

(function(){

 var $w = $(window);

var $circ = $('.animated-circle');

 var $circZwei= $('.animated-circle-zwei');
 var $circDrei= $('.animated-circle-drei');
 var $circVier= $('.animated-circle-vier');

//var $progCount = $('.progress-count'); //var $prog2 = $('.progress-indicator-2'); // var $progCountZwei = $('.progress-count-zwei'); // var $progCountDrei = $('.progress-count-drei'); // var $prog3= $('.progress-indicator-3');

var wh, h, sHeight, partOne, partTwo, partThree, partFour;

 function setSizes1(){

wh = $w.height()+150;

   s=$("#a1").offset().top+$(window).innerHeight(); //ist der Abstand vom Anfang der Seite bis nach der Summary
   s2=$("#a2").offset().top+$(window).innerHeight();//+140; //Erster Abschnitt h1- H2
   s3=$("#a3").offset().top+$(window).innerHeight()-50;
   s4=($("#a4").offset().top)+250; //zweiter Abschnitt h2-h3

h = $('body').height()-$(window).innerHeight(); partOne =s-wh;

   partTwo= s2-(wh+partOne);//wh;
   partThree=s3-(wh+partTwo+partOne);
   partFour=s4-(wh+partThree+partTwo+partOne);

}

setSizes1();

$w.on('scroll', function(){ var percOne = Math.max(0, Math.min(1, $w.scrollTop()/partOne));

   var percTwo = Math.max(0, Math.min(1, ($w.scrollTop()-partOne)/partTwo));
   var percThree = Math.max(0, Math.min(1, ($w.scrollTop()-partTwo-partOne)/partThree));
   var percFour = Math.max(0, Math.min(1, ($w.scrollTop()-partThree-partTwo-partOne)/partFour));
   updateProgress1(percTwo,percThree,percFour);
 }).on('resize', function(){
   setSizes1();
   $w.trigger('scroll');
 });


function updateProgress1(percTwo,percThree,percFour){

var circle_offset = 63 * percTwo;

   //var circle_offset_eins = 126 * percOne;
   var circle_offset_zwei = 63 * percThree;
   var circle_offset_drei = 63 * percFour;

$circZwei.css({ "stroke-dashoffset" : 63 - circle_offset });

   //$circ.css({
   //  "stroke-dashoffset" : 126 - circle_offset_eins
   //});
   $circDrei.css({
     "stroke-dashoffset" : 63 - circle_offset_zwei
   });
   $circVier.css({
     "stroke-dashoffset" : 63 - circle_offset_drei
   });
 //  $progCountZwei.html(Math.round(percTwo * 100) + "%");
 //  $progCount.html(Math.round(percOne * 100) + "%");
 //  $progCountDrei.html(Math.round(percThree * 100) + "%");

// $prog2.css({width : perc*100 + '%'});

 //  $prog2.css({width : perc*100 + '%'});
 //  $prog2.css({width : perc*100 + '%'});

}

}());