I have a list of cards where I am using masonry. Whenever a new card is added, I need to reload masonry. Unfortunately, I'm unsure how to call the function to accomplish this.
mounted(){
let wrapper = this.$refs.wrapper;
let msnry = new Masonry(wrapper, {
itemSelector: '.note',
gutter: 10,
percentPosition: true
});
}
watch: {
array: function(val) { // watching for changes
if(val){
msnry.reloadItems(); // reloading items
msnry.layout(); // rerendering layout
}
}
}
Should msnry be globally defined? I noticed that in the React tutorial, it's called in the same way. How should I approach this?