npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-gallery-layout

v0.0.5

Published

Using css3 realize like Google Photo layout vue component

Downloads

9

Readme

vue-gallery-layout npm package

自适应画廊布局组件

这是一个使用(近乎)纯 CSS 实现类似 Google Photo 图片列表的自适应布局组件;这里 近乎 实际上是指需要提前获知图片的比例或者宽高。具体原理请参照此处

例子

例子

另可参考 example 文件夹的 gallery-layout-example.html

特点

  • 每个 box 等比拉伸
  • box 在水平方向将占满每行,无多余空白
  • 每行的高度保持相同,底部对齐

PS: 自适应指:高宽均不可控

安装

npm install vue-gallery-layout -s

用法

局部引入

import VueGalleryLayout from 'vue-gallery-layout';

// demo.vue
...
export default {
  components: {
    VueGalleryLayout
  }
}

全局引入

import VueGalleryLayout from 'vue-gallery-layout';
import Vue from 'vue';

Vue.use(VueGalleryLayout);

Broswer 引入

// 全局暴露变量 VueGalleryLayout
<script src="../dist/vue-gallery-layout.js"></script>
<script>
  new Vue({
    el: '#app',
    components: {
      GalleryLayout
    }
  })
</script>

具体使用

<template>
  <div>
    <gallery-layout
      :items="items"
      :box-container-class="boxContainerClass"
      :box-init-ratio="boxInitRatio">
      <template slot-scope="scope">
        <div>{{ scope.item.width }}</div>
      </template>
    </gallery-layout>
  </div>
</template>

<script>
export default {
  //...

  data() {
    return {
      items: [
        {
          {
            id: 1,
            width: 200,
            height: 100
            // ratio: 2
          },
          {
            id: 2,
            width: 300,
            height: 200
            // ratio: 1.5
          }
        }
      ],
      boxContainerClass: 'box-container-margin',
      boxInitRatio: 100
    }
  }
}
</script>

<style>
  .box-container-margin {
    margin: 4px;
  }
</style>

props

  • items: Array<[item...]>

    • item: Object<{width, height, ratio, id}>
      • id: Any 标识符
      • width: Number 宽,必需
      • height: Number 高,必需
      • ratio: Number, width / height,有 ratio 则不需要 width 以及 height
  • boxContainerClass: String,默认为''; box 容器 class

  • boxInitRatio: Number,默认 200;

    假设大部分 box 的比例 2: 1,初始屏幕宽度为 1600px,你希望可以大部分情况下可以容纳 4 个 box,那么你的 boxInitRatio 小于 200。注意:由于自适应的存在,每行容纳 box 实际上是由 boxInitRatio, item 的 ratio,每行宽度决定的。

扩展(高层)组件

LICENSE

MIT