All Projects → shershen08 → Vue Masonry

shershen08 / Vue Masonry

Licence: mit
💠 Vue.js directive for masonry blocks layouting ✅

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Masonry

masonry-css
Create mosaic grid, like masonry, with css only
Stars: ✭ 17 (-96.66%)
Mutual labels:  layout, masonry
Egjs Infinitegrid
A module used to arrange card elements including content infinitely on a grid layout.
Stars: ✭ 751 (+47.54%)
Mutual labels:  layout, masonry
Driveway
pure CSS masonry layouts
Stars: ✭ 607 (+19.25%)
Mutual labels:  layout, masonry
React Xmasonry
Simple, minimalistic and featured native masonry layout for React JS.
Stars: ✭ 62 (-87.82%)
Mutual labels:  layout, masonry
Shuffle
Categorize, sort, and filter a responsive grid of items
Stars: ✭ 2,170 (+326.33%)
Mutual labels:  layout, masonry
Flexlib
FlexLib是一个基于flexbox模型,使用xml文件进行界面布局的框架,融合了web快速布局的能力,让iOS界面开发像写网页一样简单快速
Stars: ✭ 1,569 (+208.25%)
Mutual labels:  layout, masonry
Masonry Layout
An efficient and fast web component that gives you a beautiful masonry layout
Stars: ✭ 43 (-91.55%)
Mutual labels:  layout, masonry
egjs-grid
A component that can arrange items according to the type of grids
Stars: ✭ 188 (-63.06%)
Mutual labels:  layout, masonry
svelte-bricks
Naive Svelte Masonry component without column balancing (ragged columns at the bottom)
Stars: ✭ 22 (-95.68%)
Mutual labels:  layout, masonry
Timi
iOS 高仿Timi记账,欢迎star,THX
Stars: ✭ 469 (-7.86%)
Mutual labels:  masonry
We Vue
we-vue, 不只是 vue.js + weui!
Stars: ✭ 493 (-3.14%)
Mutual labels:  vuejs2
Vue Boilerplate Template
🍎 Efficient development of web SPA using Vue.js(2.*) + Webpack + Element-ui + Pwa + Vuex + Vuex-router + Vue-i18n + Dayjs + Lodash.
Stars: ✭ 461 (-9.43%)
Mutual labels:  vuejs2
Vue Mq
📱 💻 Define your breakpoints and build responsive design semantically and declaratively in a mobile-first way with Vue.
Stars: ✭ 474 (-6.88%)
Mutual labels:  vuejs2
Vue Grid Layout
A draggable and resizable grid layout, for Vue.js.
Stars: ✭ 5,170 (+915.72%)
Mutual labels:  vuejs2
Douban
Douban book website demo by server side render
Stars: ✭ 468 (-8.06%)
Mutual labels:  vuejs2
Vue Music
cloud-music(网易云音乐)
Stars: ✭ 500 (-1.77%)
Mutual labels:  vuejs2
Waterfall.js
Tired of use creepy hacks or heavy ways to get a Grid based on Pinterest?
Stars: ✭ 458 (-10.02%)
Mutual labels:  layout
Vue Swatches
🎨 Help the user picking beautiful colors!
Stars: ✭ 456 (-10.41%)
Mutual labels:  vuejs2
Vue Socket.io Extended
✌️⚡️ Socket.io bindings for Vue.js and Vuex (inspired by Vue-Socket.io)
Stars: ✭ 506 (-0.59%)
Mutual labels:  vuejs2
Dashboard
A dashboard scaffolding based on Vue.js 3.0 created by Vite.
Stars: ✭ 497 (-2.36%)
Mutual labels:  vuejs2

vue-masonry

DEPENDENCIES status

Current version: 0.12.0

Vue.js directive for masonry blocks layouting. Original masonry library.

Plugin DEMO available 🎉, JSFiddle DEMO

The plugin can be easily integrated with different CSS Frameworks. Check this Tailwind CSS DEMO.

You can also clone the basic demo repository vue-masonry + vue-cli webpack.

Usage

Install via NPM

  • 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.

Usage with build tools

  • 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="containerId" transition-duration="0.3s" item-selector=".item">
        <div v-masonry-tile class="item" v-for="(item, index) in blocks">
           <!-- block item markup -->
        </div>
    </div>
    

Usage directly in the browser

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/[email protected]/dist/vue-masonry-plugin-window.js"></script>
var VueMasonryPlugin = window["vue-masonry-plugin"].VueMasonryPlugin
Vue.use(VueMasonryPlugin)

Properties

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. Can be a selector string or a number;
  • origin-left="false" - set to group elements to the right instead of left by default;
  • origin-top="false" - set to group elements to the bottom instead of top by default;
  • stamp=".stamp" - specifies which elements are stamped within the layout;
  • gutter=".gutter-block-selector" - specifies [horizontal space between item elements]. Can be a selector string or a number. (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 columns;
  • horizontal-order="true" - lays out items to (mostly) maintain horizontal left-to-right order;
  • stagger="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.
  • destroy-delay="0" - Amount of time (in milliseconds) to wait before unloading masonry via masonry.destroy() when the container is destroyed. This is useful during page/route transitions to ensure the layout is consistent while the transition takes place.

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('containerId') method. As of 0.11.8 your can pass id of the block where you want to trigger the redraw.

(If you use old version < 0.10.11 it can still be Vue.redrawVueMasonry(), but please consider to upgrade)

NUXT ssr implementation

The best way to implement this is to use the no-ssr plugin.

  1. Create a file in your plugins folder called vue-masonry.js with the following contents:
import Vue from 'vue'
import {VueMasonryPlugin} from 'vue-masonry'

Vue.use(VueMasonryPlugin)
  1. Add this plugin to your nuxt.config.js
  plugins: [
    { src: '~/plugins/vue-masonry', ssr: false }
  ]

(NB make sure ssr is set to false)

  1. Add no-ssr and the markup for your vue-masonry to a component:

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 implementation of vue-masonry with nuxt ssr can be found here - https://github.com/richlloydmiles/example-vue-masonry-ssr

Contributing

Thanks to all the contributors for making the plugin better!

Questions, bugs

Known issues

  • Minor API change (JAN 2018). If you suddenly see error: 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 issue

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].