• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

    ngFlowGrid: AngularJS控制的自适应瀑布流布局(无jquery依赖)

    原作者: [db:作者] 来自: 网络 收藏 邀请

    开源软件名称:

    ngFlowGrid

    开源软件地址:

    https://gitee.com/eisneim/ngFlowGrid

    开源软件介绍:

    ngFlowGrid

    pinterest layout like responsive image grid for AngularJS app with no jQuery dependency;

    preview

    #Installation

    bower install ngFlowGrid#latest

    1.include angularJS and ngFlowGrid to your page:

    <script src="path/angular.min.js"></script><script src="src/ngFlowGrid.js"></script>

    2.add ngFlowGrid to your app's dependency:

    var myApp = angular.module('myAppName', ['ngFlowGrid']);

    3.use ngFlowGrid directive in you html code:

    <ul class="flowGrid" ng-flow-grid="homePageGrid" min-item-width="200">	<li class="flowGridItem" ng-repeat="item in items">		<a href=""><img ng-src="{{item.img}}"></a>		<h2>{{item.description}}</h2>	</li></ul>

    4.add some basic css to format the layout

    *{box-sizing: border-box;}.flowGrid:before,.flowGrid:after{	content: "";	display: table;}.flowGrid:after{	clear:both;}.flowGridItem{ margin-bottom:10px;}.flowGridItem img{width:100%;}.flowGridColumn{	float: left;	padding-left: 10px;}.flowGridColumn:last-of-type{	padding-right: 10px;}

    5.control the grid in your controller:

    app.controller('appCtrl',['$scope','fgDelegate',function($scope,fgDelegate){		$scope.updateGrid = function(){		var homePageGrid = fgDelegate.getFlow('homePageGrid');			// then you can:		homePageGrid.minItemWidth += 20;    	homePageGrid.refill(true);	}}]);

    take look at demo app;

    #Directive options###ngFlowGridgive a name for your grid, so that you can controll mutil grid in one page.###itemSelector(default:'.flowGridItem')###minItemWidth(default:150)this value will affect how many columns you have, the smaller it is the more columns there will be;

    #Servicethrough fgDelegate service you can get flow object and controll it in your controller or directive:

    ###new(option)options are:

    • container: container element.
    • name: string,the name of new grid.
    • itemSelector: string
    • minItemWidth: number, this will affect how many columns in grid;

    ###getFlow(name)this will return a flowgrid object ,and you can controll that grid throght this object

    • minItemWidth:number
    • container:element
    • autoCalculation: boolean
    • columnsHeights: array
    • itemsHeights: object
    • items: array of element
    • refill([forceRefill]) : calculate culums based on minItemWidth,and put items into columns; [forceRefill]:boolean;
    • itemsChanged(): tell flow grid you have added or removed items in your controller; before you call this method, make sure ngRepeat is finished rendering ,so you should call it like this:
     	// make sure ngRepeat is finished rendering	$scope.$watch('$last',function(){		fgDelegate.getFlow('demoGrid').itemsChanged();	});
    • empty() : remove all items inside of columns

    鲜花

    握手

    雷人

    路过

    鸡蛋
    该文章已有0人参与评论

    请发表评论

    全部评论

    专题导读
    热门推荐
    阅读排行榜

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap