Vue
by kabanoki
HTML
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/vue-waterfall.min.js"></script>
<div id="app">
<waterfall :line-gap="200" :watch="items">
<waterfall-slot
v-for="(item, index) in items"
:width="item.width"
:height="item.height"
:order="index"
:key="item.id"
>
<span>({{item.id}})</span>
</waterfall-slot>
</waterfall>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
.vue-waterfall-slot {
border: 1px #dcdcdc solid;
text-align: center;
vertical-align: middle;
}
Vue
new Vue({
el: "#app",
components: {
'waterfall': Waterfall.waterfall,
'waterfall-slot': Waterfall.waterfallSlot
},
data: {
items: [
{id:1, width: 120, height:120},
{id:2, width: 220, height:150},
{id:3, width: 150, height:220},
{id:4, width: 160, height:320},
{id:5, width: 180, height:180},
{id:6, width: 230, height:120},
{id:7, width: 120, height:100},
{id:8, width: 50, height:200},
{id:9, width: 120, height:300},
{id:10, width: 80, height:160},
{id:11, width: 120, height:240},
{id:12, width: 100, height:100},
]
}
})