Home > Web Front-end > JS Tutorial > An in-depth exploration of the implementation of jquery waterfall flow_jquery

An in-depth exploration of the implementation of jquery waterfall flow_jquery

WBOY
Release: 2016-05-16 15:16:54
Original
1202 people have browsed it

Waterfall flow must have been popular for a few years. First, it was the wave set off by Pinterest, and then domestic design mushroomed, with many examples of waterfalls popping up, such as Mogujie, Mark’s (but recently it has been involved in pornography, and it seems to have been teased), and Taobao’s “Wow” ". These are great examples. Today I want to talk about waterfall flow again. First, I want to satisfy my own wish and write a detailed introduction (I dare not call myself a tutorial). Second, I want to give everyone a reference. Because there are a lot of searches, but they give you a plug-in and teach you how to configure it. Of course, there are also many other experts who have carefully done many tutorials, such as the waterfall flow tutorial posted by Sister Amy on imooc, which is also great. My purpose is to try my best to explain some common demos to everyone, and integrate the design patterns I have learned before, which is equivalent to a simple demo.

Absolute layout

Not much to say, let’s watch a demo first

js

var cal = (function() {
  "use strict";
  var $ = function() {
    return document.querySelectorAll.apply(document, arguments);
  }
  var arrHeight = []; //得到分列的高度
  var columns = function() { //计算页面最多可以放多少列
    var bodyW = document.body.clientWidth,
      pinW = $(".pin")[0].offsetWidth;
    return Math.floor(bodyW / pinW);
  }
  var getIndex = function(arr) { //获得最小高度的index
      var minHeight = Math.min.apply(null, arr); //获得最小高度
      for (var i in arr) {
        if (arr[i] === minHeight) {
          return i;
        }
      }
    }
    //根据列数确定第一排img的高度并放入数组当中。
  var setWidth = function() { //通过列数设置宽度
    var col = columns(), //获得最后一列
      main = $('#main')[0]; //获得罩层
    main.style.width = col * $('.pin')[0].offsetWidth + "px";
  }
  var overLoad = function(ele) {
    var index = getIndex(arrHeight),
      minHeight = Math.min.apply(null, arrHeight), //获取最小高度
      pins = $('.pin'),
      style = ele.style;
    style.position = "absolute";
    style.top = minHeight + "px"; //设置当前元素的高度
    style.left = pins[index].offsetLeft + "px";
    arrHeight[index] += ele.offsetHeight;
  }
  var init = function() {
    var pins = $(".pin"),
      col = columns();
    setWidth(); //设置包裹容器的宽度
    for (var i = 0, pin; pin = pins[i]; i++) {
      if (i < col) { //存储第一排的高度
        arrHeight.push(pin.offsetHeight);
      } else {
        overLoad(pin); //将元素的位置重排
      }
    }
  }
  window.onload = init;
  //...执行自动更新操作。
  //添加当,滚动到一定位置的时候,添加html节点.
  //得到最低高度和序号,获得临界位置
  //模仿加载数据
  var dataInt = [{
    'src': '1.jpg'
  }, {
    'src': '2.jpg'
  }, {
    'src': '3.jpg'
  }, {
    'src': '4.jpg'
  }, {
    'src': '1.jpg'
  }, {
    'src': '2.jpg'
  }, {
    'src': '3.jpg'
  }, {
    'src': '4.jpg'
  }];

  function isLoad() { //是否可以进行加载
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
      wholeHeight = document.documentElement.clientHeight || document.body.clientHeight,
      point = scrollTop + wholeHeight; //页面底部距离header的距离
    var arr = $('.pin');
    var lastHei = arr[arr.length - 1].getBoundingClientRect().top;
    return (lastHei < point) &#63; true : false;
  }
  var dealScroll = (function() {
    var main = $('#main')[0],
      flag = true;
    return function() {
      console.log("trigger");
      if (isLoad() && flag) {
        for (var i = 0, data; data = dataInt[i++];) {
          var div = document.createElement('div');
          div.innerHTML = temp(data.src);
          div.className = "pin";
          main.appendChild(div);
          overLoad(div); //和上面的overload有耦合性质
        }
        flag = false;
        setTimeout(function() { //控制滑行手速,时间越长对速度的滑动时间影响越大。
          flag = true;
        }, 1000);
      }
    }
  })();
  window.addEventListener('scroll', function() {
    dealScroll();
  }, false);

  function temp(src) {
    return `
    <div class="box">
      <img src="http://cued.xunlei.com/demos/publ/img/P_00${src}"/>
    </div>
  `;
  }

})();

Copy after login

CSS

$font:10px/1.5 sans-serif,"Microsoft YaHei","Arial";
html{
 height: 100%;
 width: 100%;
 font:$font;
}
  #main{
    position: relative;
    &::after{
     display:block;
     content:'';
     clear:both;
    }
  }
  .pin{
    padding: 15px 0 0 15px;
    float:left;
  }
  .box{
    padding: 10px;
    border:1px solid #ccc;
    box-shadow: 0 0 6px #ccc;
    border-radius: 5px;
  }
  .box img{
    width:162px;
    height:auto;
  }

Copy after login

HTML

<div id="main">
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_001.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_002.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_003.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_004.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_005.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_006.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_007.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_008.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_009.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_010.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_011.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_012.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_013.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_014.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_015.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_016.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_017.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_018.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_019.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_020.jpg" />
      </div>
    </div>
    <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_021.jpg" />
      </div>
    </div>
  </div>
  <script type="text/javascript" src="./dist/index.entry.js"></script>

Copy after login

This should be considered the most commonly used layout, but it consumes higher performance. However, with some refactoring of the design, these can be avoided, let's take a look at it in detail.
Regarding html and css, you can check the console or make a copy directly.

 <div class="pin">
      <div class="box">
        <img src="http://cued.xunlei.com/demos/publ/img/P_001.jpg" />
      </div>
    </div>
Copy after login

This is a pin box inside the main container box and is also the most basic layout unit. (Here, we would like to thank Xunlei UED for the pictures provided) Our pages are actually spliced ​​together by pin units, with padding set inside to create a spacing effect.

I won’t go into details here.
Next let's take a look at the js principle.

JS implementation principle

In fact, the main difficulty of the waterfall style is how to arrange the images neatly in the corresponding columns and when to start refreshing and loading the images.
The main logic and algorithm for neatly arranging pictures is to first obtain how many columns can be placed in the container, and then, through calculation, store the height of the first column, and then traverse the remaining heights (except for the elements in the first column) and place them respectively. Enter the column with the smallest height. Add one by one, and finally end the traversal.
The settings for starting the refresh are very simple. The waterfall refresh is only related to one event, that is, window.onscroll. The main algorithm is that when the page slides to the lowest height, it starts loading nodes and adding them. Of course, the number of nodes added is not fixed.
Let’s start with the code. I will explain it in three parts. One is the arrangement of images, the other is setting the loading position. In addition, I will add a responsive loading.

Picture Arrangement

var $ = function() {
    return document.querySelectorAll.apply(document, arguments);
  }
  var arrHeight = []; //得到分列的高度
  var columns = function() { //计算页面最多可以放多少列
    var containerW = $("#main")[0].clientWidth,
      pinW = $(".pin")[0].offsetWidth;
    return Math.floor(containerW / pinW);
  }
  var getIndex = function(arr) { //获得最小高度的index
      var minHeight = Math.min.apply(null, arr); //获得最小高度
      for (var i in arr) {
        if (arr[i] === minHeight) {
          return i;
        }
      }
    }
    //根据列数确定第一排img的高度并放入数组当中。
  var setCenter = (function() { //通过列数设置宽度
    var main = $('#main')[0]; //获得罩层
    var getPadding = function() { //设置padding
      var col = columns(); //获得最后一列
      var padding = main.clientWidth - col * $('.pin')[0].offsetWidth;
      return padding / 2;
    }
    var getComputedStyle = function(ele) { //兼容IE的支持情况
      if (window.getComputedStyle) {
        return window.getComputedStyle(ele);
      } else {
        return ele.currentStyle;
      }
    }
    var getPinPad = function() { //获得pin的padding值
      var pin = $(".pin")[0];
      return parseInt(getComputedStyle(pin).paddingLeft);
    }
    return function() { //设置宽度
      main.style.padding = `0 ${getPadding()}px 0 ${getPadding()-getPinPad()}px`;
    }
  })();
  var overLoad = function(ele) {
    var index = getIndex(arrHeight),
      minHeight = Math.min.apply(null, arrHeight), //获取最小高度
      pins = $('.pin'),
      style = ele.style;
    style.position = "absolute";
    style.top = minHeight + "px"; //设置当前元素的高度
    style.left = pins[index].offsetLeft + "px";
    arrHeight[index] += ele.offsetHeight;
  }
  //初始化时执行函数
  var init = function() {
      var pins = $(".pin"),
        col = columns();
      setCenter(); //设置包裹容器的宽度
      for (var i = 0, pin; pin = pins[i]; i++) {
        if (i < col) { //存储第一排的高度
          arrHeight.push(pin.offsetHeight);
        } else {
          overLoad(pin); //将元素的位置重排
        }
      }
    }
Copy after login

There are a total of 7 functions (large functions) and one variable. Let’s talk about the idea. First of all, the function executed after the page is onloaded is init. You must know that a js program must have its entrance. The key depends on how you find it. Then we go deep into the init function body and observe. The business logic executed in init is to store the height of the first row of elements and then rearrange the remaining elements. Use the columns function to get the maximum number of columns that can be placed in the current window, and then set the center of the container (just set it through padding). Next, traverse the pin's cell box, store the height of the first row of elements in the arrHeight array, and add the remaining The elements below are rearranged. There is no need to explain other functions. Let’s focus on the overLoad function.

overLoad

var overLoad = function(ele) {
    var index = getIndex(arrHeight),
      minHeight = Math.min.apply(null, arrHeight), //获取最小高度
      pins = $('.pin'),
      style = ele.style;
    style.position = "absolute";
    style.top = minHeight + "px"; //设置当前元素的高度
    style.left = pins[index].offsetLeft + "px";
    arrHeight[index] += ele.offsetHeight;
  }
Copy after login

There is a getIndex function in overLoad to get the index of the minimum height, and then you can set the position of the incoming ele element (absolute positioning). top is the px value of the minimum height in the array, and left is set for the first row. The left margin position of the Index element. Finally update the height, ok!!! that's enough.
Set loading location

var dataInt = [{
    'src': '1.jpg'
  }, {
    'src': '2.jpg'
  }, {
    'src': '3.jpg'
  }, {
    'src': '4.jpg'
  }, {
    'src': '1.jpg'
  }, {
    'src': '2.jpg'
  }, {
    'src': '3.jpg'
  }, {
    'src': '4.jpg'
  }];

  function isLoad() { //是否可以进行加载
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
      wholeHeight = document.documentElement.clientHeight || document.body.clientHeight,
      point = scrollTop + wholeHeight; //页面底部距离header的距离
    var arr = $('.pin');
    var lastHei = arr[arr.length - 1].getBoundingClientRect().top;
    return (lastHei < point) &#63; true : false;
  }
  //处理滑动
  var dealScroll = (function() {
    var main = $('#main')[0],
      flag = true;
    return function() {
      if (isLoad() && flag) {
        for (var i = 0, data; data = dataInt[i++];) {
          var div = document.createElement('div');
          div.innerHTML = temp(data.src);
          div.className = "pin";
          main.appendChild(div);
          overLoad(div); //和上面的overload有耦合性质
        }
        flag = false;
        setTimeout(function() { //控制滑行手速,时间越长对速度的滑动时间影响越大。
          flag = true;
        }, 200);
      }
    }
  })();

  function temp(src) {
    return `
    <div class="box">
      <img src="http://cued.xunlei.com/demos/publ/img/P_00${src}"/>
    </div>
  `;
  }

Copy after login

Actually, the essence is in the previous part. This is just a means of loading data. Of course, you can click to load (manual trigger), or other loading methods. Of course, how you set it up is entirely up to you. Therefore, follow the trend and still scroll down to load. Continue and find the entry function->dealScroll. The task of this function is to determine whether loading can be performed through the isload function. Let’s take a look at the isload function. This is the key point of rolling loading.

 function isLoad() { //是否可以进行加载
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
      wholeHeight = document.documentElement.clientHeight || document.body.clientHeight,
      point = scrollTop + wholeHeight; //页面底部距离header的距离
    var arr = $('.pin');
    var lastHei = arr[arr.length - 1].getBoundingClientRect().top;
    return (lastHei < point) &#63; true : false;
  }
Copy after login

通过计算得出,页面底部距视口的位置(工具条下部) 与 最后一个元素的绝对位置比较,如果 滑动距离超过,则启用加载。
yeah~ That's over.
back to dealScroll

接下来就是看加载的部分了,这个部分其实也没什么说的,就是创建一个div节点,然后将他放到容器的最后,并且通过overLoad函数来处理该节点的位置。 另外在该函数的末尾,我设置了一个控制滑动速度的trick,通过对函数的节流,防止有时候,请求过慢,用户重复发送请求,造成资源浪费。
然后,这一部分也可以告一段落了。

响应式

最后一部分就是响应式了, 这部分,也超级简单,只要你封装性做的好,其实这一部分就是添加一个resize事件就over了。我们继续找入口函数。

  var resize = (function() {
      var flag;
      return function(fn) {
        clearTimeout(flag);
        flag = setTimeout(function() { //函数的节流,防止用户过度移动
          fn();
          console.log("ok")
        }, 500);
      }
})();


Copy after login

同样,这里使用到了函数节流的思想,要知道,作为一个程序员,永远不要以为 用户 干不出什么 傻事. 比如,没事的时候拖着浏览器窗口玩,放大,缩小,再放大... 其实,这事我经常干,因为没有女朋友,写代码写累了,就拖浏览器玩。 所以,考虑到我们单身狗的需求,使用函数节流是非常有必要的。 感兴趣的童鞋,可以参考我前面的文章,进行学习。 说明一下,这里的回调函数指的就是init函数,但是 需要对init做些改动。详见。

 var update = function(ele) { //当resize的时候,重新设置
    ele.style.position = "initial";
  }
  //初始化时执行函数
  var init = function() {
      var pins = $(".pin"),
        col = columns();
      arrHeight = []; //清空高度
      setCenter(); //设置包裹容器的宽度
      for (var i = 0, pin; pin = pins[i]; i++) {
        if (i < col) { //存储第一排的高度
          arrHeight.push(pin.offsetHeight);
          update(pin);
        } else {
          overLoad(pin); //将元素的位置重排
        }
      }
    }
Copy after login

上面需要加入update,对新的第一排元素进行更新。
然后就可以直接搬过来使用即可。
这就是绝对是布局的大部分内容了。

总结一下吧,这个部分我应该是,重构Amy的例子的,总的来说是遵循了,最少知识原则的,一个函数尽量不带参数,就一定不带参数了. 还有就是 一个函数 的书写,不超过33行,并且尽量的实现细粒度表达,实现函数的重用。 当然,我写的这一部分还是有很多问题的,js组织结构还是比较混论的,一些hack直接与主要业务逻辑放在一起。 我也相信,读者们肯定有自己独特的见解,写出来的代码,肯定比我好太多!!! (这个是肯定的.)

列式布局

同样,先看demo.
https://jsfiddle.net/jimmyTHR/amyvoagm/5/

我们对比一下上面的,绝对式布局。 一个很大的却别就是,页面的计算量大大降低。 什么意思呢? 即,页面重绘的次数减少,操作节点数减少,页面布局更加清晰。

首先我们来看一下他的html内容。我这里就不贴出全部了,同样,只列出一个基本单元。

<div id="container">
    <span class="column">
    <span class="panel">
          <img src="http://cued.xunlei.com/demos/publ/img/P_009.jpg" alt="">
          <p></p>
        </span>
      </span>
      </div>
Copy after login

上面就是一个基本的单元,需要注意的是,我们需要设置一个column表示一列。而span.panel就是一个基本砖块。
好了,不在这地方磨叽了。我们再来看一下scss.

$font:10px/1.5 sans-serif,"Microsoft YaHei","Arial";
html,body{
  height: 100%;
  width: 100%;
  font:$font;
  background-color: #eee;
}
#container{
  width:100%;
  height: 100%;
  position: relative;
  text-align: center;
}
.column{
  display: inline-block;
  width:210px;
  vertical-align: top;
  padding:0 10px;
  .panel{
    padding: 10px 0 10px 0;
    display: block;
    text-align: center;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    background-color: #fff;
    text-decoration: none;
  }
}
Copy after login

这我也不磨叽了,scss这里需要引入normalize.scss进行和谐处理。
html和css介绍完了,我们要开始搬砖了。

JS原理

上面说了,列式布局简直算是完虐绝对式布局. 绝对式布局,简直就像10元/天 的搬砖工。而列式布局就是站在那看他搬砖的监工。 同样都是搬砖的,一个卖苦力,一个秀智商。简直了!!!
听了逼逼,我们来直面一下惨淡的人生。

列式布局的原理其实和绝对式布局没有太大的却别。
同样也有3个部分, 一是页面加载自适应,二是滑动加载,三是响应式布局。
分别讲解:

加载自适应

我们先看一下代码吧:

var $ = function() { //一个hacks
  return document.querySelectorAll.apply(document, arguments);
}
var waterFall = (function(){
  //初始化布局
  var arrHeight = []; //列的高度
  var columns = function() { //计算页面最多可以放多少列
      var bodyW = $('#container')[0].clientWidth,
        pinW = $(".column")[0].offsetWidth;
      return Math.floor(bodyW / pinW);
    }
    //设置瀑布流居中
  var getHtml = function() {
      var cols = $('.column'), //获得已有的列数
        arrHtml = [];
      for (var i = 0, col; col = cols[i++];) {
        var htmls = col.innerHTML.match(/<img(&#63;:.|\n|\r|\s)*&#63;p>/gi); //获取一个columns的
        arrHtml = arrHtml.concat(htmls);
      }
      return arrHtml;
    }
    //获得数组中最低的高度
  var getMinIndex = function() { //获得最小高度的index
    var minHeight = Math.min.apply(null, arrHeight); //获得最小高度
    for (var i in arrHeight) {
      if (arrHeight[i] === minHeight) {
        return i;
      }
    }
  }
  var createCol = function() {
      var cols = columns(), //获得列数
        contain = $("#container")[0];
      contain.innerHTML = ''; //清空数据
      for (var i = 0; i < cols; i++) {
        var span = document.createElement("span");
        span.className = "column";
        contain.appendChild(span);
      }
    }
    //初始化列的高度
  var initHeight = function() {
      var cols = columns(),
        arr = [];
      for (var i = 0; i < cols; i++) {
        arr.push(0);
      }
      arrHeight = arr;
    }
   //创建一个ele并且添加到最小位置
  var createArticle = function(html){
    var cols = $('.column'),
      index = getMinIndex(),
      ele = document.createElement('article');
    ele.className = "panel";;
    ele.innerHTML = html;
    cols[index].appendChild(ele);
    arrHeight[index] += ele.clientHeight;
  }
  //遍历获得的html然后添加到页面中
  var reloadImg = function(htmls) {
    for (var i = 0, html, index; html = htmls[i++];) {
      createArticle(html);
    }

  }
  var onload = function() {
      var contain = $("#container")[0], //获得容器
        arrHtml = getHtml(); //获得现有的所有瀑布流块
      //创建列,然后进行加载
      createCol();
      //初始化arrHeight
      initHeight();
      //进行页面的重绘
      reloadImg(arrHtml);
      return this;
    }
})();

Copy after login

看见一个程序,先找他的入口函数,显然,一开始应该是onload,那么,观察onload函数. 可以发现,里面一共有4个函数.
由于用户的宽度不确定,所以我们的列数也不是一定的。这时候,就需要获取实际尺寸然后进行一个计算才行。然后需要对原有的数据,进行重排。

所以,getHtml就是来获取一开始的原有数据(innerHTML);
然后就可以更具宽度来添加列了。
createCol函数就是更具宽度来添加列的。
这时候,我们需要一个数组(arrHeight)来保存每列的高(默认都为0).
然后就可以进行页面重排=>reloadImg(arrHtml), arrHtml就是原始数据。
好,我们这里初级搬砖完成。
接下来,是要开始加固了。

滑动加载

这个应该算是我直接copy过来的,所以说,函数写的好,重用性也是棒棒哒。

show u code
 var isLoad=function() { //是否可以进行加载
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
      wholeHeight = document.documentElement.clientHeight || document.body.clientHeight,
      point = scrollTop + wholeHeight; //页面底部距离header的距离
    var lastHei = Math.min.apply(null,arrHeight);
    return (lastHei < point) &#63; true : false;
  }

  var dealScroll = (function(){
    window.onscroll = ()=>{dealScroll();}
    var container = $('#container')[0];
    return function(){
      if(isLoad()){
        for(var i = 0,html,data;data = dataInt[i++]; ){
          html = tpl.temp(data.src); //获得数据然后添加模板
          createArticle(html);
        }
      }
      return this;
    }
  })();

Copy after login

同样的isload,同样的dealScroll的逻辑。 这里需要说明的就是,createArticle就是给最低高度列添加砖块的函数。
然后,就没有然后啦.

响应式布局

这个我也是直接copy过来的。

 var resize = (function(){
    window.onresize = ()=>{resize();};
    var flag;
    return function(){
      clearTimeout(flag);
      flag = setTimeout(()=>{onload();},500);
      return this;
    }
Copy after login

需要说明的是,onload,dealScroll,resize这3个函数,后面我都加上"return this". 目的是可以进行链式调用,以备后面重用性的需要。

最后说两句

响应式布局的流行真的很突然,慢慢的,慢慢的我没有防备。 感觉在11年和12年的时候简直就是一种风尚,而现在回味过来,看这个布局方法,感觉精髓依在的。 我们也可以进行变通,我们可以往右滑,右边节点增加。 获得抖抖手机,节点增加,这些都是可以完成的。(因为主要的逻辑我们已经有了,只是判断增加的方式变了而已)。

我这里写的一部分内容,应该算是(云网页)吧。 大家有兴趣可以直接拷贝到自己的IDE或者Sublime里面进行测试,数据都是放在云端的。

大家如果真的对前端有兴趣的话,造轮子就是一个最好的办法。就像我们小时候做计算题,事实上这些题目早就有了,已经有无数人做过。那我们做还有什么意义呢? 如果你这样想的话,你已经把你自己给平庸化了(不是平凡化)。 你抱着的是一个,这个别人做过了,我做了又没有什么用,还没有别人做的好,我不想做。。。 但是,有没有想过,为什么你叫这个名字,你为什么在这个城市长大,为什么能看到我写的这篇文章。 因为道理很简单,你就是一个很独特的人, 你做的任何事情都是不可复制的。 当你写瀑布流的时候,你浏览的网站,看过的资料,写的代码。这些串联起来都是你最独特的flag。 所以,造轮子不是waste 而恰恰相反是worthy,同样就是code review一样。只有自己做过才知道,这个东西,我真的知道。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template