Reputation: 131
I'm using jGravity on a loading page. The page loads different divs during the page load and I want to apply jGravity to every appearing div, but only once. This is the code I have so far, but it applies jGravity to every div.bubble everytime, so it messes up everything.
function showDiv() {
if(counter == 0 ) { counter ++; return; }
$('#whatsapp').find('#bubble-' + counter).show().jGravity({
target: 'div.bubble',
ignoreClass: 'ignoreMe',
weight: 25,
depth: 5,
drag: true
});
counter ++;
Thank you in advance
Upvotes: 1
Views: 32
Reputation: 1570
I can't test at the moment but I think this would work for your needs:
function showDiv() {
if(counter == 0 ) { counter ++; return; }
$('#whatsapp').find('#bubble-' + counter + ':not(.ignoreMe)').addClass('ignoreMe').show().jGravity({
target: 'div.bubble',
ignoreClass: 'ignoreMe',
weight: 25,
depth: 5,
drag: true
});
counter ++
It adds a class ignoreMe
to each item as it goes and ignores the items with that class afterwards using the :not
pseudo class.
Upvotes: 2