Skip to content

Commit 1ca89b3

Browse files
committed
2 parents 828937f + 410bb4f commit 1ca89b3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

parallax.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,22 @@
333333
self.isBusy = false;
334334
});
335335
}
336+
},
337+
destroy: function(el){
338+
var i,
339+
parallaxElement = $(el).data('px.parallax');
340+
parallaxElement.$mirror.remove();
341+
for(i=0; i < this.sliders.length; i+=1){
342+
if(this.sliders[i] == parallaxElement){
343+
this.sliders.splice(i, 1);
344+
}
345+
}
346+
$(el).data('px.parallax', false);
347+
if(this.sliders.length === 0){
348+
$(window).off('scroll.px.parallax resize.px.parallax load.px.parallax');
349+
this.isReady = false;
350+
Parallax.isSetup = false;
351+
}
336352
}
337353
});
338354

@@ -356,7 +372,11 @@
356372
$.extend($this.data('px.parallax'), options);
357373
}
358374
if (typeof option == 'string') {
359-
Parallax[option]();
375+
if(option == 'destroy'){
376+
Parallax['destroy'](this);
377+
}else{
378+
Parallax[option]();
379+
}
360380
}
361381
})
362382
};

0 commit comments

Comments
 (0)