Last active
February 17, 2016 09:29
-
-
Save furenku/cb307e8a5c85f9fd7fba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* habia un pedo con iscroll y las posiciones, entonces fue necesario | |
colocarlo fuera y aplicarle 8===o ~~~ un transform: transate(0,0,0) para que se | |
viera sobre iscroll */ | |
var iscroll = new IScroll('#wrapper', { | |
scrollbars: true, | |
mouseWheel: true, | |
interactiveScrollbars: true, | |
shrinkScrollbars: 'scale', | |
probeType: 3, | |
// snap: true, | |
// fadeScrollbars: true | |
}); | |
var scrollerH = $('#scroller').height(); | |
var headerFijo = false; | |
function updatePosition () { | |
var activeIndex = ( Math.round( this.y / $('#wrapper').height() ) ) * -1; | |
$('.menu_btn').eq(activeIndex).addClass('active'); | |
$('.menu_btn').eq(activeIndex).siblings().removeClass('active'); | |
//posicion header | |
var head = $('#header_fake'); | |
if( head.hasClass('hidden') ) { | |
head = $('#header'); | |
}; | |
var positionHead = head.offset().top; | |
if( activeIndex > positionHead ) { | |
if( ! headerFijo ) { | |
$('header#header').detach().prependTo('#wrapper'); | |
$('#header').css({ | |
'-webkit-transform' : 'translate(0px,0px) translateZ(0px)', | |
'-moz-transform' : 'translate(0px,0px) translateZ(0px)', | |
'-ms-transform' : 'translate(0px,0px) translateZ(0px)', | |
'-o-transform' : 'translate(0px,0px) translateZ(0px)', | |
'transform' : 'translate(0px,0px) translateZ(0px)' | |
}); | |
$('#header_fake').removeClass('hidden'); | |
headerFijo = true; | |
} | |
} else { | |
if ( headerFijo ) { | |
$('header#header').detach().insertAfter('#header_fake'); | |
$('#header').css({ | |
'-webkit-transform' : '', | |
'-moz-transform' : '', | |
'-ms-transform' : '', | |
'-o-transform' : '', | |
'transform' : '' | |
}); | |
$('#header_fake').addClass('hidden'); | |
headerFijo = false; | |
}; | |
}; | |
// | |
if (activeIndex > 0) { | |
$('.start_icon').animate({ | |
opacity:0 | |
},200); | |
$(['#logo','#menu_icon','#floating_menu','#contact_icon'].join(',')).animate({ | |
opacity:1 | |
},200); | |
} else if (activeIndex === 0){ | |
$('.start_icon').animate({ | |
opacity:1 | |
},200); | |
$(['#logo','#menu_icon','#floating_menu','#contact_icon'].join(',')).animate({ | |
opacity:0 | |
},200); | |
} | |
console.log(activeIndex + ' ' + positionHead);//debug | |
// $('#pct_stat span').html( Math.round((((this.y / $('#wrapper').height())*-1)*100)/3) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment