Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

clusterize in vue

NotificationsYou must be signed in to change notification settings

vue-comps/vue-clusterize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An implementation ofClusterize.js invue.

Works similar tov-for but only takes enough data to fill the viewport 3 times.
This data is then splitted into three clusters which will move and get filled with the right data on scrolling.

Disclaimer

Only forwebpack workflows.

No jQuery dependency

Install

npm install --save-dev vue-clusterize

use version 0.2.0 before vue1.0.24

Usage

# link the components upcomponents:"clusterize":require("vue-clusterize")# or ES6importclusterizefrom"vue-clusterize"components: {"clusterize": clusterize}
<clusterize:data="rowsData"><!-- default slot will be used as a template for a single row --><div>{{data}}</div><!-- (optional) loading slot will be displayed in each cluster which is busy fetching data - only with dynamic data --><pslot="loading">loading...</p></clusterize>

For examples seedev/.

Available variables in template

Nametypedescription
dataObjecta single datapiece (seebinding-name in props)
loadingNumberwill be 0 when finished loading data (only with dynamic data)
indexNumberindex of the datapiece
heightNumberthe height of a single row

you can add your own variables with therow-watchers prop.

example:

<clusterize@get-data="getData"><divv-if="!loading"v-bind:style="{height:height+'px'}">{{data}} - index: {{index}}</div><pslot="loading">loading...</p></clusterize>

Props

Nametypedefaultdescription
binding-nameString"data"name to access the data in your template
heightNumbernullHeight of the clusterize element
auto-heightBooleanfalseIf autoheight should be used (see below)
manual-startBooleanfalserendering doesn't start onready (callstart on the component instance instead)
dataArray[]static data to render
scroll-topNumber0sets scrollTop
scroll-leftNumber0sets scrollLeft
cluster-size-facNumber1.5determines the cluster size relative to visible size
row-heightNumbernullenforced row-height, will be determined at runtime when not set
templateString-row template (defaults to slot content)
styleObject-to pass trough style (vue object)
row-watchersObject{height: {vm: this, prop:"rowHeight"}}variables, will be available in template
parent-vmObjectthis.$parentwhere to resolve components in template
flexBooleanfalseallow multiple items per row. Seeflex.
flex-initialNumber20data pieces to take for calculation of row height (should fill several rows)
flex-facNumber1reduce to reduce items per row

Autoheight

There are two ways clusterize can be used, either use a fixed height:

<clusterize:data="rowsData":height="400"v-ref:clusterize>

Or use autoheight:

<htmlstyle="height:100%"><bodystyle="height:100%"><divstyle="position:relative"><clusterize:data="rowsData"auto-height>

In this case clusterize will always fill the nearest parent element with eitherposition:relative; orposition:absolute;.
Keep in mind, thatpadding of the parent will be ignored. If you need a padding, use a wrapper<div>.

Dynamic data

The clusterize instance emits two events to get dynamic data:

<clusterize@get-data="getData"@get-data-count="getDataCount">
methods:  #Forthefirstdatapiece,firstandlastwillbe0  getData:function(first,last,cb){      #somehowgetdatacb(data)}  getDataCount:function(cb){cb(dataCount)}

To issue a manual redraw, callredraw() on the clusterize instance.

If you want to enforce a scroll-to-top use thescrollTop prop.

Flex

When using theflex prop, the usage changes. You will now recieve a array of row items per row which you can use in av-for:

<clusterize:data="rowsData"flex><divstyle="display:flex;align-items:center;justify-content:space-between"><divv-for="d in data">{{d}}</div></div></clusterize>

The row height, items per row and rows per cluster will be recalculated on resize of clusterize.

Development

Clone repository.

npm installnpm runtest

Browse tohttp://localhost:8080/.

To-Do

  • use html5 history mode or document.store to save scroll position

License

Copyright (c) 2016 Paul PflugradtLicensed under the MIT license.

About

clusterize in vue

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp