Skip to content

Instantly share code, notes, and snippets.

@pesblog
Created May 7, 2014 07:56
Show Gist options
  • Save pesblog/295eca7ba243f165cb37 to your computer and use it in GitHub Desktop.
Save pesblog/295eca7ba243f165cb37 to your computer and use it in GitHub Desktop.
$(someMyOneDiv).on('inview', function(e, isInView, visiblePartX, visiblePartY) {
var elem = $(this);
if (elem.data('inviewscroller')) {
elem.off('scroll.inview');
elem.removeData('inviewscroller');
}
if (isInView) {
elem.data('inviewscroller', true);
elem.on('scroll.inview', $.throttle(200, function() {
if (visiblePartY == 'top') {
elem.data('seenTop', true);
} else if (visiblePartY == 'bottom') {
elem.data('seenBottom', true);
} else {
elem.data('seenTop', true);
elem.data('seenBottom', true);
}
if (elem.data('seenTop') && elem.data('seenBottom')) {
elem.unbind('inview');
// elem.off('scroll.inview'); これは要らないかな?
//ここに処理を書く
}
}));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment