setupTabPressedStates = function() { downSpring.setSpringConfig(rebound.SpringConfig.fromQcTensionAndFriction(100, 5.5)); downSpring.addListener({ onSpringUpdate: function (spring) { var progress = spring.getCurrentValue(); var scale = transitionForProgressInRange(progress,1.0,0.92); tabs[downIndex].style['webkitTransform'] = 'scale('+scale+')'; tabs[downIndex].style['MozTransform'] = 'scale('+scale+')'; } }); }
setupMainSpring = function() { mainSpring.setSpringConfig(rebound.SpringConfig.fromQcTensionAndFriction(4.5, 5.7)); mainSpring.addListener({ onSpringUpdate: function (spring) { // Progress from 0 to n var progress = spring.getCurrentValue(); // Slide the tabs over var xTranslation = transitionForProgressInSteps(progress,navOffsets); // Pixel snap when the spring is nearing rest on non-retina displays if (Math.abs(spring.getVelocity()) < 0.05 && window.devicePixelRatio < 1.1) xTranslation = Math.floor(xTranslation); nav.style['webkitTransform'] = 'translate3d(' + xTranslation + 'px, 0, 0)'; nav.style['MozTransform'] = 'translate3d(' + xTranslation + 'px, 0, 0)'; // Other transitions $("#slides li").each(function(i, val) { var slideProgress = 1 - Math.abs(progress - i); // Slide and scale the images if (slideProgress > 0) { // Only bother if the slide is visible // Slide and scale var x = (i * viewportWidth) - (progress * viewportWidth); var scale = transitionForProgressInRange(slideProgress,0.6,1.0); val.style['webkitTransform'] = 'translate3d(' + x + 'px, 0, 0) scale(' + scale +')'; val.style['MozTransform'] = 'translate3d(' + x + 'px, 0, 0) scale(' + scale +')'; // Fade in the caption when nearing rest if (i < captions.length) { var captionOpacity = transitionForProgressInRange(slideProgress,-8.0,1.0); captions[i].style['opacity'] = captionOpacity; } } // Hide the off-screen images so they don't reveal themselves if you resize the browser val.style['opacity'] = (slideProgress > 0) ? 1.0 : 0.0; // Show the current tab as black, others grey var tabOpacity = transitionForProgressInRange(clampedProgress(slideProgress),0.2,1,0); tabs[i].style['opacity'] = tabOpacity; }); } }); }
function updateSpringConfig() { s.setSpringConfig( rebound.SpringConfig.fromOrigamiTensionAndFriction(tension,friction) ); }