vue-masonry
Advanced tools
Comparing version 0.10.16 to 0.10.17
{ | ||
"name": "vue-masonry", | ||
"version": "0.10.16", | ||
"version": "0.10.17", | ||
"description": "masonry layout for vue.js", | ||
@@ -5,0 +5,0 @@ "main" : "src/masonry.plugin.js", |
@@ -1,2 +0,1 @@ | ||
import Vue from 'vue' | ||
import Masonry from 'masonry-layout' | ||
@@ -19,9 +18,10 @@ import ImageLoaded from 'imagesloaded' | ||
const EVENT_IMAGE_LOADED = 'vuemasonry.imageLoaded' | ||
const EVENT_DESTROY = 'vuemasonry.destroy' | ||
const stringToBool = function(val) { return (val + '').toLowerCase() === 'true'} | ||
const stringToBool = function (val) { return (val + '').toLowerCase() === 'true' } | ||
const collectOptions = function(attrs) { | ||
var res = {}; | ||
const collectOptions = function (attrs) { | ||
var res = {} | ||
var attributesArray = Array.prototype.slice.call(attrs) | ||
attributesArray.forEach(function(attr) { | ||
attributesArray.forEach(function (attr) { | ||
if (Object.keys(attributesMap).indexOf(attr.name) > -1) { | ||
@@ -34,4 +34,2 @@ res[attributesMap[attr.name]] = (attr.name.indexOf('origin') > -1) ? stringToBool(attr.value) : attr.value | ||
const Events = new Vue({}) | ||
export const VueMasonryPlugin = function () {} | ||
@@ -41,2 +39,4 @@ | ||
const Events = new Vue({}) | ||
Vue.directive('masonry', { | ||
@@ -50,3 +50,3 @@ props: ['transitionDuration', ' itemSelector'], | ||
const masonry = new Masonry(el, collectOptions(el.attributes)) | ||
const masonryDraw = function() { | ||
const masonryDraw = function () { | ||
masonry.reloadItems() | ||
@@ -68,2 +68,8 @@ masonry.layout() | ||
}) | ||
Events.$on(EVENT_DESTROY, function (eventData) { | ||
masonry.destroy() | ||
}) | ||
}, | ||
unbind: function (el, nodeObj) { | ||
Events.$emit(EVENT_DESTROY) | ||
} | ||
@@ -78,3 +84,3 @@ }) | ||
}) | ||
// eslint-disable-next-line | ||
new ImageLoaded(el, function () { | ||
@@ -96,2 +102,2 @@ Events.$emit(EVENT_IMAGE_LOADED, { | ||
} | ||
} | ||
} |
Sorry, the diff of this file is too big to display
180
38649