I have a this function
function toDiv() {
$(".wrap")))
$('.barfill').each(function(){
var width=$(this).data('width');
$(this).animate({ width: width }, 500);
var $perctext = $('<div>', {'class': 'perctext', text: width});
$perctext.appendTo(this);
$perctext.delay(500).each(function(a) {
$(this).delay(a * 250).animate({
'left': width
}, 1000);
});
});
else {}
}
that runs after the element appears on the pane by using this.
function toView(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
I want it to run ONCE and when the element is on the pane again the function won't trigger again.
I applied .one() to the parent function so it runs only once but that didn't do the trick.
You can check the Fiddle Demo to clarify the problem further.
Note: I updated this question for clarity, since it seemed to create some misunderstandings.