Wookmark-jQuery-master 瀑布流插件使用介绍,含我的测试DEMO

要求

    • 必备知识

      本文要求基本了解 Html/CSS,  JavaScript/JQuery。html

    • 开发环境

      Dreamweaver CS6 / Chrome浏览器jquery

    • 演示地址

      演示地址 资料下载浏览器

 

 

测试预览截图(抬抬你的鼠标就能够看到演示地址哦):app

2014-06-25_080450

程序核心代码看这里:dom

$(function(){
    
        function show(){    
                var colors=["#BA4A3A","#5BB5D6","#8EA83B","#EE5C92","#8AC9B5","#604127","#E8A03B","#AF032D","#000000","#506575"];
                var tags=["女人","男人","电影","宝儿","安妮海瑟薇","数码"];
                for(var i in colors){
                    var index = Math.round(Math.random() * 59);
                    var img="../Public/Pic/test/"+index+".jpg";
                    var index2=Math.round(Math.random() * (tags.length-1));  //随机获取一个标签
                
                    $('#tiles').append(" <li style='background:"+colors[i]+"' class='clearFix'><div style='background:#FFF'><img src='"+img+"' width='230' /></div><p>是一个熊!!不是一个游戏机!!</p><span>#"+tags[index2]+"</span></li> ");
                }
        
        }
        
         //初始化二十条数据
         show();
         show();
            
    
    /*瀑布流*/
    $('#tiles').imagesLoaded(function() {
        var handler = null;
        // Prepare layout options.
        var options = {
          autoResize: true, // This will auto-update the layout when the browser window is resized.
          container: $('#main'), // Optional, used for some extra CSS styling
          offset: 15, // Optional, the distance between grid items
          itemWidth: 230, // Optional, the width of a grid item
          direction :'right'
        };
        
        //瀑布流布局
        function applyLayout() {
          $('#tiles').imagesLoaded(function() {
            // Destroy the old handler        //是否须要销毁旧的布局
            if (handler.wookmarkInstance) {
              handler.wookmarkInstance.clear();
            }

            // Create a new layout handler. //从新布局瀑布流
            handler = $('#tiles li');
            handler.wookmark(options);    //传入配置参数
          });
        }

          //当滚动条高度大于等于最后一个盒子高度 Ajax请求数据
          //绑定到scroll事件上
         
        function onScroll(event) {
          // Check if we're within 100 pixels of the bottom edge of the broser window.
          var winHeight = window.innerHeight ? window.innerHeight : $(window).height(); // iphone fix
          var closeToBottom = ($(window).scrollTop() + winHeight > $(document).height() - 100);

          if (closeToBottom) {    
            show();
            applyLayout();  //执行布局
          }
        };

        // Capture scroll event.
        $(window).bind('scroll', onScroll);

        // Call the layout function.
        handler = $('#tiles li');  //获取盒子
        handler.wookmark(options);    //初始化瀑布流
      });    
      
    
      
    
});

Wookmark-jQuery瀑布流插件介绍和下载:http://www.wookmark.com/jquery-plugin/iphone

2014-06-25_065331

 

官方在线演示地址:http://www.wookmark.com/布局

2014-06-25_065747

 

 

关于动态的上传图片将到后续的文章中介绍,有兴趣的博友能够多多关注哦!!学习

“呵呵”结束了,请原谅本童鞋目前”脑残又缺少”的语言组织能力,欢迎你们来拍砖来劈斧,因为本人水平有限,文章在表述和代码方面若有不妥之处,欢迎批评指正。测试

 

如以上文章或连接对你有帮助的话,别忘了在文章结尾处轻轻点击一下 “还不错”按钮或到页面右下角点击 “赞一个” 按钮哦。你也能够点击页面右边“分享”悬浮按钮哦,让更多的人阅读这篇文章。spa

 

做者: Li-Cheng
因为本人水平有限,文章在表述和代码方面若有不妥之处,欢迎批评指正。留下你的脚印,欢迎评论哦。你也能够关注我,一块儿学习哦!
相关文章
相关标签/搜索