好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

waterfall

waterfall 介绍

这是瀑布流布局 插件 ,类似于 Pinterest、花瓣、发现啦。

使用

html:

<div id="container"></div>

引入jquery,handlebars和waterfall(注:waterfall 默 认返回json格式数据并使用handlebars模板渲染json数据,你也可以在options中配置使用其它JavaScript模板如mustache解析json数据或者直接返回html):

<script src="/path/jquery.min.js"></script>

<script src="/path/handlebars.js"></script>

<script src="/path/waterfall.min.js"></script>

template:

<script id="waterfall-tpl" type="text/x-handlebars-template">

//template content

</script>

script:

$('#container').waterfall({

itemCls: 'waterfall-item',

prefix: 'waterfall',

fitWidth: true,

colWidth: 240,

gutterWidth: 10,

gutterHeight: 10,

align: 'center',

minCol: 1,

maxCol: undefined,

maxPage: undefined,

bufferPixel: -50,

containerStyle: {

position: 'relative'

},

resizable: true,

isFadeIn: false,

isAnimated: false,

animatio nop tions: {

},

isA utop refill: true,

checkImagesLoaded: true,

path: undefined,

dataType: 'json',

p ara ms: {},

loadingMsg: '<div><img src="data:image/gif;base64" alt=""><br />Loading...</div>',

state: {

isDuringAjax: false,

isProcessingData: false,

isResizing: false,

curPage: 1

},

// callbacks

callbacks: {

/*

* loadingStart

* @p ara m {Object} loading $('#waterfall-loading')

*/

loadingStart: function($loading) {

$loading.show();

//console.log('loading','start');

},

/*

* loadingFinished

* @p ara m {Object} loading $('#waterfall-loading')

* @p ara m {Boolean} isBeyondMaxPage

*/

loadingFinished: function($loading,isBeyondMaxPage) {

if ( !isBeyondMaxPage ) {

$loading.fadeOut();

//console.log('loading finished');

} else {

//console.log('loading isBeyondMaxPage');

$loading.remove();

}

},

/*

* loadingError

* @p ara m {String} xhr,"end" "error"

*/

loadingError: function($message,xhr) {

$message.html('Data load faild,please try again later.');

},

/*

* renderData

* @p ara m {String} data

* @p ara m {String} dataType,"json","jsonp","html"

*/

renderData: function (data,dataType) {

var tpl,

template;

if ( dataType === 'json' || dataType === 'jsonp' ) { // json or jsonp format

tpl = $('#waterfall-tpl').html();

template = Handlebars.compile(tpl);

return template(data);

} else { // html format

return data;

}

}

},

debug: false

});

options

Name

Type

Default value

Description

itemCls

String

'waterfall-item'

瀑布流数据块class

prefix

String

'waterfall'

瀑布流元素前辍

fitWidth

Boolean

true

是否自适应父元素宽度

colWidth

Integer

240

瀑布流每列的宽度

gutterWidth

Integer

10

数据块水平间距

gutterHeight

Integer

10

数据块垂直间距

align

String

'center'

数据块相对于容器对齐方式,'align','left','right'

minCol

Integer

1

数据块最小列数

maxCol

Integer

undefined

数据块最多 显示 列数, 默 认undefined,最大列数无限制

maxPage

Integer

undefined

最多 显示 多少页数据, 默 认undefined,无限下拉

bufferPixel

Integer

-50

滚动时,窗口 底部 到瀑布流最小高度列的距离 > bufferPixel时, 自动 加载新数据

containerStyle

Object

{position: 'relative'}

瀑布流 默 认样式

resizable

Boolean

true

缩放时是否触发数据重排

isFadeIn

Boolean

false

新插入数据是否使用fade动画

isAnimated

Boolean

false

resize时数据是否 显示 动画

animatio nop tions

Object

{}

resize动画 效果 ,isAnimated为true时有效

isA utop refill

Boolean

true

当文档小于窗口可见区域, 自动 加载数据

checkImagesLoaded

Boolean

true

是否 图片 加载完成后开始排列数据块。如果直接 后台 输出 图片 尺寸,可设置为false,强烈建议从 后台 输出 图片 尺寸,设置为false

path

Array,Function

undefined

瀑布流数据 分页 url,可以是数组如["/popular/page/","/"] => "/popular/page/1/",或者是根据 分页 返回 一个 url 方法 如:function(page) { return '/populr/page/' + page; } => "/popular/page/1/"

dataType

String

'json'

瀑布流返回数据格式,'json','jsonp','html'

p ara ms

Object

{}

瀑布流数据请求参数,{type: "popular",tags: "travel",format: "json"} => "type=popular&tags=travel&format=json"

loadingMsg

html

见下面 代码

加载 提示 进度条,html

callbacks

Object

见下面 代码

callback

debug

Boolean

false

开启debug

网站地址 : http://wlog.cn/waterfall/

GitHub: https://github.com/bingdian/waterfall

网站描述: jquery 瀑布流布局 插件 ,类似于 Pinterest

waterfall官方网站

官方网站: http://wlog.cn/waterfall/

如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。

查看更多关于waterfall的详细内容...

  阅读:33次

上一篇

下一篇

第1节:jquery-labelauty    第2节:jQuery.fontFlex    第3节:jQuery.Marquee    第4节:Nestable    第5节:magnificent.js    第6节:vegas    第7节:gridster.js    第8节:jQuery-Knob    第9节:Parallax.js    第10节:fakeLoader.js    第11节:query-mousewheel    第12节:jquery.danmu.js    第13节:jquery.toast.js    第14节:jquery.fileDownload    第15节:enlarge.js    第16节:OrgChart    第17节:Uploadify    第18节:cPager.js    第19节:timeline.js    第20节:magnify.js    第21节:jTable    第22节:jquery.barrager.js    第23节:lightbox2    第24节:toastr.js    第25节:jQuery-Validation-Engine    第26节:lazyload.js    第27节:Fluidbox.js    第28节:jQuery.toTop    第29节:eadremaining.js    第30节:SelectPage.js    第31节:fullPage.js    第32节:jquery-migrate    第33节:jBox    第34节:hc-sticky    第35节:selectize.js    第36节:paroller.js    第37节:vide    第38节:skippr    第39节:jQuery-Autocomplete    第40节:imagesloaded    第41节:Stellar.js    第42节:Mapael    第43节:lazy-line-painter    第44节:jquery-confirm    第45节:imgLiquid    第46节:ResponsiveSlides.js    第47节:mgGlitch.js    第48节:jquery-validation    第49节:Wookmark-jQuery    第50节:FitVids.js    第51节:vex    第52节:Garlic.js    第53节:artDialog    第54节:isotope    第55节:jquery.mosaicflow    第56节:Viewer.js    第57节:At.js    第58节:animsition    第59节:jquery.mask.js    第60节:lightslider    第61节:Lettering.js    第62节:ssi-uploader    第63节:jquery.fileapi    第64节:sly.js    第65节:Galpop    第66节:OwlCarousel2    第67节:jQueryRotate.js    第68节:metismenu    第69节:jPlayer    第70节:fancyInput    第71节:FooTable    第72节:jquery-textext    第73节:jquery-mockjax    第74节:jQuery.mmenu    第75节:paper-collapse    第76节:jqPaginator.js    第77节:Trumbowyg    第78节:bxslider    第79节:jquery.transit    第80节:busy-load    第81节:jquery.color.js    第82节:jcSlider.js    第83节:onepage-scroll    第84节:ScrollMagic    第85节:jquery.zoom.js    第86节:jcarousel    第87节:icheck    第88节:datetimepicker    第89节:turn.js    第90节:OverlayScrollbars    第91节:jQuery-contextMenu    第92节:slick-lightbox.js    第93节:Filterizr    第94节:jquery-backstretch    第95节:Waterwheel-Carousel    第96节:Snabbt.js    第97节:images-grid.js    第98节:share-button    第99节:jquery.imageuploader.js    第100节:gridstack.js    第101节:multi-select.js    第102节:midnight.js    第103节:waterfall    第104节:jQuery.NumPad    第105节:Magnific-Popup    第106节:threesixty-slider    第107节:Swipebox    第108节:textillate.js    第109节:star-rating-svg    第110节:jquery-textcomplete    第111节:jmpress.js    第112节:jquery-touchswipe    第113节:jScrollPane    第114节:overhang.js    第115节:distpicker    第116节:pagePiling.js    第117节:FlexSlider    第118节:AOS.js    第119节:threesixty.js    第120节:alertify.js    第121节:s-gallery    第122节:chosen.js    第123节:formvalidation    第124节:Parsley.js    第125节:jQuery-File-Upload    第126节:colorbox    第127节:particleground    第128节:Datedropper.js    第129节:fancyBox    第130节:cxSelect    第131节:jquery.scrollTo    第132节:Waterfall.js    第133节:jquery-dropdown    第134节:jstree    第135节:daterangepicker    第136节:FitText.js    第137节:Remodal    第138节:slider.js    第139节:sidr    第140节:peity.js    第141节:jquery-steps    第142节:jquery.typeahead.js    第143节:CardTabs    第144节:DataTables    第145节:jquery.timelinr.js    第146节:jquery.gray.js    第147节:jquery.timeago.js    第148节:jquery.panzoom    第149节:Raty    第150节:jquery.pep.js    第151节:Treeview    第152节:SelectMenu.js    第153节:Inputmask    第154节:jquery.ez-plus.js    第155节:zTree    第156节:timer.jquery    第157节:Jcrop    第158节:MagicSuggest    第159节:jGravity    第160节:jquery.sticky-sidebar.js    第161节:cxCalendar    第162节:Paginathing.js    第163节:fullcalendar    第164节:roundabout    第165节:Toolbar.js    第166节:evol-colorpicker    第167节:adaptive-backgrounds.js    第168节:jQuery之家    第169节:scrollorama    第170节:Scrollify    第171节:Progression.js    第172节:Slick.js    第173节:unveil    第174节:unlock.js    第175节:nanoScroller.js    第176节:messenger    第177节:Smoothslides    第178节:Tabslet    第179节:jquery-plugin-circliful    第180节:pickadate.js    第181节:tooltipster    第182节:jQuery-menu-aim    第183节:perfect-scrollbar    第184节:multiscroll.js    第185节:grumble.js    第186节:clndr.js    第187节:iziModal    第188节:noty    第189节:Notify.js    第190节:Zoomove    第191节:chardin.js