Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
vue-masonry
Advanced tools
Current version: 0.11.5
Vue.js directive for masonry blocks layouting. Original masonry library.
Plugin DEMO available 🎉, JSFiddle DEMO
You can also clone the basic demo repository vue-masonry + vue-cli webpack.
Get from npm: npm install vue-masonry --save
or from bower bower install vue-masonry
Make sure that the masonry library is included; for example using cdn link: <script async defer src="https://cdnjs.cloudflare.com/ajax/libs/masonry/4.0.0/masonry.pkgd.min.js"></script>
or in other convenient way.
In your Vue app you'll have the following code:
import Vue from 'vue'
// import ES6 style
import {VueMasonryPlugin} from 'vue-masonry';
// or using CJS
// const VueMasonryPlugin = require('vue-masonry').VueMasonryPlugin
Vue.use(VueMasonryPlugin)
<div v-masonry transition-duration="0.3s" item-selector=".item">
<div v-masonry-tile class="item" v-for="(item, index) in blocks">
<!-- block item markup -->
</div>
</div>
Since v 0.11.3 in-browser usage is available using a direct script inclusion on the page like so:
<script src="https://unpkg.com/vue-masonry@0.11.3/dist/vue-masonry-plugin-window.js"></script>
var VueMasonryPlugin = window["vue-masonry-plugin"].VueMasonryPlugin
Vue.use(VueMasonryPlugin)
Properties that are currently available reproduce most of those on the original masonry plugin:
item-selector=".item"
- list element DOM item selector;transition-duration="0.3s
- duration of transitions;column-width="#test"
- element selector for column width;origin-left="false"
- set to group elements to the right instead of left by defaultorigin-top="false"
- set to group elements to the bottom instead of top by defaultstamp=".stamp"
- specifies which elements are stamped within the layoutgutter=".gutter-block-selector"
- specifies [horizontal space between item elements]
(https://masonry.desandro.com/options.html#gutter). Set gutter to an Element or Selector String to use the outer width of the element.fit-width="true"
- sets the width of the container to fit the available number of columnshorizontal-order="true"
- lays out items to (mostly) maintain horizontal left-to-right orderstagger="0.03s"
- Staggers item transitions, so items transition incrementally after one another. Set as a CSS time format, '0.03s', or as a number in milliseconds, 30💡💡💡 If you need to manually trigger masonry layout redraw (for example in case if your tile elements amount or content has changed) you can now use this.$redrawVueMasonry()
method. (If you use old version < 0.10.11
it can still be Vue.redrawVueMasonry()
, but please consider to upgrade)
The best way to impliment this is to use the no-ssr plugin.
import Vue from 'vue'
import {VueMasonryPlugin} from 'vue-masonry'
Vue.use(VueMasonryPlugin)
nuxt.config.js
plugins: [
{ src: '~/plugins/vue-masonry', ssr: false }
]
(NB make sure ssr is set to false)
HTML:
<no-ssr>
<div v-masonry transition-duration="3s" item-selector=".item" class="masonry-container">
<div v-masonry-tile class="item" :key="index" v-for="(item, index) in blocks">
<p>{{item}} - {{index}}</p>
</div>
</div>
</no-ssr>
JS:
import NoSSR from 'vue-no-ssr'
export default {
components: {
'no-ssr': NoSSR
},
mounted () {
if (typeof this.$redrawVueMasonry === 'function') {
this.$redrawVueMasonry()
}
}
}
An example implimentation of vue-masonry with nuxt ssr can be found here - https://github.com/richlloydmiles/example-vue-masonry-ssr
Thanks to all the contributors for making the plugin better!
Uncaught TypeError: _vue2.default.redrawVueMasonry is not a function
- please upgrade your usage of the plugin's method redrawVueMasonry
in component methods from Vue.redrawVueMasonry()
to this.$redrawVueMasonry();
. See more details in #31 issueMIT
FAQs
masonry layout for vue.js
The npm package vue-masonry receives a total of 2,202 weekly downloads. As such, vue-masonry popularity was classified as popular.
We found that vue-masonry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.