I wrote an angular.js directive which uses stellar.js for parallax effects. When I call the same directive multiple times one after another, stellar.js will only work on the first one.
I read about $.stellar('refresh');
which should re-initialize stellar after injecting elements in the DOM, but this had no effect for me. Also calling stellar on the window had no effect.
Here is the code of my directive:
angular.module('ClientApp')
.directive('parallaxModule', function () {
return {
templateUrl: 'views/parallax-module.html',
restrict: 'E',
scope: {
data: '='
},
controller: function() {
$(function(){
$(this).stellar({
horizontalScrolling: false,
verticalScrolling: true,
verticalOffset: 50
});
});
}
};
});
This is how I use the directive:
<parallax-module data="sectionData.para"></parallax-module>
<parallax-module data="sectionData.para"></parallax-module>
And here's my template:
<div class="parallax-module" data-stellar-background-ratio="0.2">
<div class="wrapper" data-stellar-ratio="2.5">
<div class="title">{{data.title}}</div>
<div class="caption">{{data.caption}}</div>
</div>
</div>
Here's a plunker: http://plnkr.co/edit/TJbPL3dhSsiitZQWm9Qe?p=preview