https://github.com/DLHTX/waterfall-sinanews/edit/master/index.html
先将img标签中的src链接设为同一张图片(空白图片),将其真正的图片地址存储再img标签的自定义属性中(比如data-src)。当js监听到该图片元素进入可视窗口时,即将自定义属性中的地址存储到src属性中,达到懒加载的效果。
先通过计算出一排能够容纳几列元素,然后寻找各列之中所有元素高度之和的最小者,并将新的元素添加到该列上,然后继续寻找所有列的各元素之和的最小者,继续添加至该列上,如此循环下去,直至所有元素均能够按要求排列为止;
通过app.start()进入程序,然后通过ajax获取数据,之后将得到的数据拼装成html放入dom中,等待图片全部load完,进行瀑布流的布局,监听滚动事件,但是要设置节流函数,对于ajax的请求设置枷锁机制,不让它在没有接到数据的时候进行多次请求。