├── .gitignore ├── .babelrc ├── example ├── images │ ├── pg0.jpg │ ├── pg1.jpg │ ├── pg2.jpg │ ├── pg3.jpg │ ├── pg4.jpg │ └── pg5.jpg ├── index.js ├── index.html └── Example.vue ├── .travis.yml ├── src ├── index.js ├── WaterfallItem.vue └── Waterfall.vue ├── .eslintrc.js ├── .editorconfig ├── LICENSE ├── webpack.config.js ├── package.json ├── ZH_CN.md ├── webpack.example.js ├── README.md └── dist └── vue2-waterfall.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ] 5 | } -------------------------------------------------------------------------------- /example/images/pg0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PLDaily/vue2-waterfall/HEAD/example/images/pg0.jpg -------------------------------------------------------------------------------- /example/images/pg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PLDaily/vue2-waterfall/HEAD/example/images/pg1.jpg -------------------------------------------------------------------------------- /example/images/pg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PLDaily/vue2-waterfall/HEAD/example/images/pg2.jpg -------------------------------------------------------------------------------- /example/images/pg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PLDaily/vue2-waterfall/HEAD/example/images/pg3.jpg -------------------------------------------------------------------------------- /example/images/pg4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PLDaily/vue2-waterfall/HEAD/example/images/pg4.jpg -------------------------------------------------------------------------------- /example/images/pg5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PLDaily/vue2-waterfall/HEAD/example/images/pg5.jpg -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'stable' 4 | - 8 5 | branches: 6 | only: 7 | - master -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import Waterfall from './Waterfall.vue' 2 | import WaterfallItem from './WaterfallItem.vue' 3 | 4 | export { Waterfall, WaterfallItem } 5 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | es6: true 6 | }, 7 | extends: "standard", 8 | plugins: [ 9 | 'html' 10 | ], 11 | rules: { 12 | } 13 | } -------------------------------------------------------------------------------- /src/WaterfallItem.vue: -------------------------------------------------------------------------------- 1 | 6 | 11 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Example from './Example.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | /* eslint-disable no-new */ 7 | new Vue({ 8 | el: '#example', 9 | render: h => h(Example) 10 | }) 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | insert_final_newline = false 12 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | vue2-waterfall 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path') 3 | const CleanWebpackPlugin = require('clean-webpack-plugin') 4 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 5 | const pkg = require('./package.json') 6 | 7 | const banner = ` 8 | ${pkg.description} 9 | v${pkg.version} ©${new Date().getFullYear()} ${pkg.author} 10 | ${pkg.homepage} 11 | `.trim() 12 | 13 | function resolve(dir, filename = '') { 14 | return path.join(__dirname, dir, filename) 15 | } 16 | 17 | const config = { 18 | entry: './src/index.js', 19 | output: { 20 | path: resolve('dist'), 21 | publicPath: '/', 22 | library: 'Vue2Waterfall', 23 | libraryTarget: 'umd', 24 | filename: 'vue2-waterfall.js' 25 | }, 26 | externals: { 27 | 'vue': 'Vue' 28 | }, 29 | module: { 30 | rules: [ 31 | { 32 | enforce: 'pre', 33 | test: /\.(js|vue)$/, 34 | use: [{ 35 | loader: 'eslint-loader', 36 | options: { 37 | fix: true 38 | } 39 | }] 40 | }, 41 | { 42 | test: /\.js$/, 43 | exclude: /node_modules/, 44 | use: ['babel-loader'] 45 | }, 46 | { 47 | test: /\.vue$/, 48 | exclude: /node_modules/, 49 | loader: 'vue-loader', 50 | include: [resolve('src')] 51 | } 52 | ] 53 | }, 54 | plugins: [ 55 | new CleanWebpackPlugin([resolve('dist')]), 56 | new webpack.optimize.UglifyJsPlugin(), 57 | new webpack.BannerPlugin(banner), 58 | ] 59 | } 60 | module.exports = config; -------------------------------------------------------------------------------- /example/Example.vue: -------------------------------------------------------------------------------- 1 | 22 | 32 | 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue2-waterfall", 3 | "version": "3.0.1", 4 | "description": "An AutoHeight Waterfall Component For Vue2", 5 | "main": "dist/vue2-waterfall.js", 6 | "scripts": { 7 | "watch": "webpack --watch", 8 | "build": "webpack", 9 | "dev": "webpack-dev-server --config webpack.example.js --open" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/PLDaily/vue2-waterfall.git" 14 | }, 15 | "keywords": [ 16 | "vue", 17 | "waterfall" 18 | ], 19 | "author": "PLDaily ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/PLDaily/vue2-waterfall/issues" 23 | }, 24 | "homepage": "https://github.com/PLDaily/vue2-waterfall#readme", 25 | "peerDependencies": { 26 | "vue": ">=2.0.0" 27 | }, 28 | "dependencies": { 29 | "imagesloaded": "^4.1.4", 30 | "masonry-layout": "^4.2.2", 31 | "vue": "^2.5.13" 32 | }, 33 | "devDependencies": { 34 | "babel-cli": "^6.26.0", 35 | "babel-core": "^6.26.0", 36 | "babel-loader": "^7.1.2", 37 | "babel-preset-env": "^1.6.1", 38 | "clean-webpack-plugin": "^0.1.17", 39 | "css-loader": "^0.28.7", 40 | "eslint": "^4.12.1", 41 | "eslint-config-standard": "^10.2.1", 42 | "eslint-loader": "^1.9.0", 43 | "eslint-plugin-html": "^4.0.1", 44 | "eslint-plugin-import": "^2.8.0", 45 | "eslint-plugin-node": "^5.2.1", 46 | "eslint-plugin-promise": "^3.6.0", 47 | "eslint-plugin-standard": "^3.0.1", 48 | "extract-text-webpack-plugin": "^3.0.2", 49 | "file-loader": "^1.1.5", 50 | "html-webpack-plugin": "^2.30.1", 51 | "vue-loader": "^13.5.0", 52 | "vue-template-compiler": "^2.5.9", 53 | "webpack": "^3.10.0", 54 | "webpack-dev-server": "^2.9.7" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ZH_CN.md: -------------------------------------------------------------------------------- 1 | # vue2-waterfall 2 | 3 | [![Build Status](https://travis-ci.org/PLDaily/vue2-waterfall.svg?branch=master)](https://travis-ci.org/PLDaily/vue2-waterfall) 4 | [![npm](https://img.shields.io/npm/v/vue2-waterfall.svg)](https://www.npmjs.com/package/vue2-waterfall) 5 | [![npm](https://img.shields.io/npm/dt/vue2-waterfall.svg)](https://www.npmjs.com/package/vue2-waterfall) 6 | [![npm](https://img.shields.io/npm/l/vue2-waterfall.svg)](https://www.npmjs.com/package/vue2-waterfall) 7 | [![npm](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standard/standard) 8 | 9 | ## 概述 10 | > 一个基于vue2的自适应高度瀑布流组件 11 | 12 | [demo](http://67.218.146.247:8090/) 13 | 14 | ## 安装 15 | 16 | ### 安装 vue2-waterfall 17 | 18 | ```sh 19 | npm install vue2-waterfall 20 | ``` 21 | 22 | ### 加载 vue2-waterfall 模块 23 | 24 | 支持 ES6 与 commonjs 的加载方式 25 | 26 | ```js 27 | // ES6 28 | import {Waterfall, WaterfallItem} from 'vue2-waterfall'; 29 | 30 | // commonjs 31 | const Waterfall = require("vue2-waterfall").Waterfall; 32 | const WaterfallItem = require("vue2-waterfall").WaterfallItem; 33 | ``` 34 | 也可以在 html 文件中使用 `script` 标签引入脚本,访问全局变量 `Vue2Waterfall` 35 | 36 | ```js 37 | 38 | ``` 39 | 40 | ## 使用 41 | 42 | ```html 43 | 44 | item1 45 | item2 46 | item3 47 | ... 48 | 49 | ``` 50 | 51 | ## 选项 52 | 53 | | 属性 | 描述 | 默认值 | 类型 | 54 | | --------------- | ---------------------------------------------------------------- | ------------ | --------- | 55 | | options | [masonry](https://masonry.desandro.com/options.html) options | {} | Object | 56 | 57 | ## LICENSE 58 | 59 | MIT@[PLDaily](https://github.com/PLDaily) 60 | -------------------------------------------------------------------------------- /webpack.example.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path') 3 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | const HtmlWebpackPlugin = require('html-webpack-plugin') 5 | 6 | function resolve (dir, filename = '') { 7 | return path.join(__dirname, dir, filename) 8 | } 9 | 10 | const config = { 11 | entry: './example/index.js', 12 | output: { 13 | path: resolve('dist'), 14 | publicPath: '/', 15 | filename: './dist/example.js' 16 | }, 17 | devtool: 'inline-source-map', 18 | devServer: { 19 | contentBase: resolve('example'), 20 | compress: true, 21 | hot: true 22 | }, 23 | module: { 24 | rules: [ 25 | { 26 | enforce: 'pre', 27 | test: /\.(js|vue)$/, 28 | use: [{ 29 | loader: 'eslint-loader', 30 | options: { 31 | fix: true 32 | } 33 | }] 34 | }, 35 | { 36 | test: /\.js$/, 37 | exclude: /node_modules/, 38 | use: ['babel-loader'], 39 | include: [resolve('src'), resolve('example')] 40 | }, 41 | { 42 | test: /\.vue$/, 43 | exclude: /node_modules/, 44 | loader: 'vue-loader', 45 | include: [resolve('src'), resolve('example')], 46 | options: { 47 | loaders: { 48 | css: ExtractTextPlugin.extract({ 49 | use: ['css-loader'], 50 | fallback: 'vue-style-loader' 51 | }) 52 | } 53 | } 54 | }, 55 | { 56 | test: /\.(png|jpg|gif|svg)$/, 57 | use: [{ 58 | loader: 'file-loader' 59 | }] 60 | } 61 | ] 62 | }, 63 | plugins: [ 64 | new ExtractTextPlugin({ 65 | filename: 'example.css' 66 | }), 67 | new webpack.HotModuleReplacementPlugin(), 68 | new HtmlWebpackPlugin({ 69 | template: resolve('example', 'index.html'), 70 | filename: 'index.html' 71 | }) 72 | ] 73 | } 74 | module.exports = config; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue2-waterfall 2 | 3 | [![Build Status](https://travis-ci.org/PLDaily/vue2-waterfall.svg?branch=master)](https://travis-ci.org/PLDaily/vue2-waterfall) 4 | [![npm](https://img.shields.io/npm/v/vue2-waterfall.svg)](https://www.npmjs.com/package/vue2-waterfall) 5 | [![npm](https://img.shields.io/npm/dt/vue2-waterfall.svg)](https://www.npmjs.com/package/vue2-waterfall) 6 | [![npm](https://img.shields.io/npm/l/vue2-waterfall.svg)](https://www.npmjs.com/package/vue2-waterfall) 7 | [![npm](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standard/standard) 8 | 9 | [访问中文版](https://github.com/PLDaily/vue2-waterfall/blob/3.0/ZH_CN.md) 10 | 11 | ## Overview 12 | > An AutoHeight Waterfall Component For Vue2 13 | 14 | [demo](http://67.218.146.247:8090/) 15 | 16 | ## Install 17 | 18 | ### Install vue2-waterfall 19 | 20 | ```sh 21 | npm install vue2-waterfall 22 | ``` 23 | 24 | ### Import vue2-waterfall 25 | 26 | ES6/commonjs import style is supported. 27 | 28 | ```js 29 | // ES6 30 | import {Waterfall, WaterfallItem} from 'vue2-waterfall'; 31 | 32 | // commonjs 33 | const Waterfall = require("vue2-waterfall").Waterfall; 34 | const WaterfallItem = require("vue2-waterfall").WaterfallItem; 35 | ``` 36 | or link as a `script` in an html file and access global variable `Vue2Waterfall`. 37 | 38 | ```js 39 | 40 | ``` 41 | 42 | ## Usage 43 | 44 | ```html 45 | 46 | item1 47 | item2 48 | item3 49 | ... 50 | 51 | ``` 52 | 53 | ## options 54 | 55 | | Option | Description | default | type | 56 | | --------------- | ---------------------------------------------------------------- | ----------- | --------- | 57 | | options | [masonry](https://masonry.desandro.com/options.html) options | {} | Object | 58 | 59 | ## LICENSE 60 | 61 | MIT@[PLDaily](https://github.com/PLDaily) 62 | -------------------------------------------------------------------------------- /src/Waterfall.vue: -------------------------------------------------------------------------------- 1 | 6 | 121 | -------------------------------------------------------------------------------- /dist/vue2-waterfall.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * An AutoHeight Waterfall Component For Vue2 3 | * v3.0.1 ©2020 PLDaily 4 | * https://github.com/PLDaily/vue2-waterfall#readme 5 | */ 6 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Vue2Waterfall=e():t.Vue2Waterfall=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=5)}([function(t,e,i){var n,o;!function(r,s){n=s,void 0!==(o="function"==typeof n?n.call(e,i,e,t):n)&&(t.exports=o)}("undefined"!=typeof window&&window,function(){"use strict";function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){i=i.slice(0),e=e||[];for(var n=this._onceEvents&&this._onceEvents[t],o=0;o