Skip to content

Commit

Permalink
Adding a method to destroy Scrollorama. This is useful for re-initial…
Browse files Browse the repository at this point in the history
…izing the plugin, and memory management.
  • Loading branch information
Jake Bellacera committed May 8, 2012
1 parent 79c1e96 commit 7d16ecf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions js/jquery.scrollorama.js
Expand Up @@ -344,6 +344,30 @@
return scrollpoints;
};

// Remove scrollorama
scrollorama.destroy = function () {
// Remove animations
for (i=0; i<blocks.length; i++) {
// Remove CSS rules
blocks[i].block.css({
top: '',
position: ''
});

// Remove scrolloroma-specific attributes
delete blocks[i].animations;
delete blocks[i].top;
delete blocks[i].pin;
}

// Unbind the window scroll event
$(window).off('scroll.scrollorama');
$('#scroll-wrap').remove();

// Remove the scrolloroma object
delete scrollorama;
};


// INIT
init();
Expand Down

0 comments on commit 7d16ecf

Please sign in to comment.