[jQuery] Clearing data from function between uses?
This code attempts to determine the position of the browser scroll bar
before clicking to a feature and then return to that position when the
feature is closed. It works. But it is also building a history of
every position for every time the feature is used, which I don't want
it to do.
So, the first time one clicks to the feature and closes - works great.
But after that, upon closing the feature, the browser runs through
every previous position before settling on the correct one for the
current open/close feature "session". So if this is the 5th time
you've clicked to the feature without refreshing the browser, you run
through 5 positions before settling on the correct one upon closing
the feature. Make any sense?
How do I clear the history between each use of the feature?
scrollPosition = {
method1: function(){
getPos = $(window).scrollTop();
$(window).data('position', getPos);
var setPos = $(window).data('position');
scrollPosition.method2 (setPos);
return;
},
method2: function(setPos){
$(".sections .toggleDropNav").click(function () {
$.scrollTo( setPos + 'px', 500 );
});
alert(setPos);
return;
}
};