diff options
Diffstat (limited to 'assets/js/index.js')
-rw-r--r-- | assets/js/index.js | 131 |
1 files changed, 48 insertions, 83 deletions
diff --git a/assets/js/index.js b/assets/js/index.js index 5d5ade0..cbcf143 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -1,96 +1,61 @@ +var map, wingr,wingl,muscler, musclel, stringr, stringl, cavity, flight_path, flight_path_length, last_point, step; + +var prev_step = 0 +step = 0; +map = Snap('#left-bits'); +wingr = map.select('#wingr'); +wingrbbox = wingr.getBBox(); +wingl = map.select('#wingl'); +winglbbox = wingl.getBBox(); +musclel = map.select('#musclel'); +musclelbbox = musclel.getBBox(); +muscler = map.select('#muscler'); +musclerbbox = muscler.getBBox(); +stringl = map.select('#stringl'); +stringlbbox = stringl.getBBox(); +stringr = map.select('#stringr'); +stringrbbox = stringr.getBBox(); +cavity = map.select('#cavity'); +cavitybbox = cavity.getBBox(); +flight_path = map.select('#path'); +flight_path_l = Snap.path.getTotalLength(flight_path); +last_point = flight_path.getPointAtLength(flight_path_length); + +console.log('step', step, 'final', flight_path_l) + +function angle(n) { + return Math.random() * (n * 2) + n; +} - - - var map, wingr,wingl,muscler, musclel, stringr, stringl, cavity, flight_path, flight_path_length, last_point, step; - - // window.onload = function () { - - step = 0; - map = Snap('#left-bits'); - wingr = map.select('#wingr'); - wingrbbox = wingr.getBBox(); - wingl = map.select('#wingl'); - winglbbox = wingl.getBBox(); - musclel = map.select('#musclel'); - musclelbbox = musclel.getBBox(); - muscler = map.select('#muscler'); - musclerbbox = muscler.getBBox(); - stringl = map.select('#stringl'); - stringlbbox = stringl.getBBox(); - stringr = map.select('#stringr'); - stringrbbox = stringr.getBBox(); - cavity = map.select('#cavity'); - cavitybbox = cavity.getBBox(); - flight_path = map.select('#path'); - - - - flight_path_length = Snap.path.getTotalLength(flight_path); - -flight_path_length= flight_path_length/100 - - last_point = flight_path.getPointAtLength(flight_path_length); +let cb = function() { -console.log ('len'+ flight_path_length); + prev_step = step + step = step + parseInt(pas.innerHTML) * 10; + if (step > flight_path_l) prev_step = step = 0 + $('#pas').text(step) + $('#prev_step').text(prev_step) + $('#step').text(step) + $('#next_step').text(flight_path_l) - - let cb=function(){step=step+100; + console.log('pas', pas.innerHTML) - Snap.animate(step, flight_path_length, function() { -//console.log('pas'); - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); + Snap.animate(prev_step, step, function(val) { + //console.log('pas'); + step = val; + moveToPoint = Snap.path.getPointAtLength( flight_path, val ); x = moveToPoint.x ; y = moveToPoint.y ; -// console.log('animating ' + x + ' ' + y); + // console.log('animating ' + x + ' ' + y); wingr.transform('translate(' + x + ',' + y + ') '+', '+wingrbbox.cx+', '+wingrbbox.cy); - },5000, mina.easeout); - - - Snap.animate(step, flight_path_length, function() { - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); - x = moveToPoint.x ; - y = moveToPoint.y ; wingl.transform('translate(' + x + ',' + y + ')' + (moveToPoint.alpha - 90)+', '+winglbbox.cx+', '+winglbbox.cy); - },5000, mina.easeout); - -Snap.animate(step, flight_path_length, function() { - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); - x = moveToPoint.x ; - y = moveToPoint.y ; - cavity.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - 90)+', '+cavitybbox.cx+', '+cavitybbox.cy+')'); - },5000, mina.easeout); - -Snap.animate(step, flight_path_length, function() { - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); - x = moveToPoint.x ; - y = moveToPoint.y ; - musclel.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - 90)+', '+musclelbbox.cx+', '+musclelbbox.cy+')'); - },5000, mina.easeout); - -Snap.animate(step, flight_path_length, function() { - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); - x = moveToPoint.x ; - y = moveToPoint.y ; - muscler.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - 90)+', '+musclerbbox.cx+', '+musclerbbox.cy+')'); + cavity.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - angle(-10))+', '+cavitybbox.cx+', '+cavitybbox.cy+')'); + musclel.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - angle(20))+', '+musclelbbox.cx+', '+musclelbbox.cy+')'); + muscler.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - angle(30))+', '+musclerbbox.cx+', '+musclerbbox.cy+')'); + stringr.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - angle(-20))+', '+stringrbbox.cx+', '+stringrbbox.cy+')'); + stringl.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - angle(9))+', '+stringlbbox.cx+', '+stringlbbox.cy+')'); },5000, mina.easeout); - -Snap.animate(step, flight_path_length, function() { - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); - x = moveToPoint.x ; - y = moveToPoint.y ; - stringr.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - 90)+', '+stringrbbox.cx+', '+stringrbbox.cy+')'); - },5000, mina.easeout); - -Snap.animate(step, flight_path_length, function() { - moveToPoint = Snap.path.getPointAtLength( flight_path, step ); - x = moveToPoint.x ; - y = moveToPoint.y ; - stringl.transform('translate(' + x + ',' + y + ') rotate('+ (moveToPoint.alpha - 90)+', '+stringlbbox.cx+', '+stringlbbox.cy+')'); - },5000, mina.easeout); - + } document.addEventListener("requestMove", cb,false); - - |