Is there a way to achieve parallax scrolling on window scroll and navigation click simultaneously? When navigating and animating the page to the top to show the target, I also want to get the window scroll unit.
How can I obtain the window scroll unit on click while the page is animating to the target position at the top?
// By using this code snippet, my aim is to retrieve the window scroll unit //
$glob(document).ready(function() {
$glob("#lookbook_navi a").bind("click",function(event){
event.preventDefault();
var target = $glob(this).attr("href");
var objWindow = $glob(window);
$window = $glob(window);
alert($window.scrollTop());
$glob("#page").animate({
"top": -($glob(target).position().top)
}, animSpeed);
});
});
// Utilizing this code to determine the window scrolling unit ///
$glob(document).ready(function(){
// Cache the Window object
$window = $glob(window);
$glob('div[data-type="lookBookTab"]').each(function(){
var $bgobj = $glob(this); // assigning the object
$glob(window).scroll(function() {
// Scroll the background at var speed
// the yPos is a negative value because we're scrolling it UP!
var yPos = -($window.scrollTop() / $bgobj.data('speed'));
// Put together our final background position
var coords = '50% '+ yPos + 'px';
// Move the background
$bgobj.css({ backgroundPosition: coords });
}); // window scroll Ends
});
});