ge">7 年之前 es6.string.italics.js 11e3a9652a first 7 年之前 es6.string.iterator.js 11e3a9652a first 7 年之前 es6.string.link.js 11e3a9652a first 7 年之前 es6.string.raw.js 11e3a9652a first 7 年之前 es6.string.repeat.js 11e3a9652a first 7 年之前 es6.string.small.js 11e3a9652a first 7 年之前 es6.string.starts-with.js 11e3a9652a first 7 年之前 es6.string.strike.js 11e3a9652a first 7 年之前 es6.string.sub.js 11e3a9652a first 7 年之前 es6.string.sup.js 11e3a9652a first 7 年之前 es6.string.trim.js 11e3a9652a first 7 年之前 es6.symbol.js 11e3a9652a first 7 年之前 es6.typed.array-buffer.js 11e3a9652a first 7 年之前 es6.typed.data-view.js 11e3a9652a first 7 年之前 es6.typed.float32-array.js 11e3a9652a first 7 年之前 es6.typed.float64-array.js 11e3a9652a first 7 年之前 es6.typed.int16-array.js 11e3a9652a first 7 年之前 es6.typed.int32-array.js 11e3a9652a first 7 年之前 es6.typed.int8-array.js 11e3a9652a first 7 年之前 es6.typed.uint16-array.js 11e3a9652a first 7 年之前 es6.typed.uint32-array.js 11e3a9652a first 7 年之前 es6.typed.uint8-array.js 11e3a9652a first 7 年之前 es6.typed.uint8-clamped-array.js 11e3a9652a first 7 年之前 es6.weak-map.js 11e3a9652a first 7 年之前 es6.weak-set.js 11e3a9652a first 7 年之前 es7.array.flat-map.js 11e3a9652a first 7 年之前 es7.array.flatten.js 11e3a9652a first 7 年之前 es7.array.includes.js 11e3a9652a first 7 年之前 es7.asap.js 11e3a9652a first 7 年之前 es7.error.is-error.js 11e3a9652a first 7 年之前 es7.global.js 11e3a9652a first 7 年之前 es7.map.from.js 11e3a9652a first 7 年之前 es7.map.of.js 11e3a9652a first 7 年之前 es7.map.to-json.js 11e3a9652a first 7 年之前 es7.math.clamp.js 11e3a9652a first 7 年之前 es7.math.deg-per-rad.js 11e3a9652a first 7 年之前 es7.math.degrees.js 11e3a9652a first 7 年之前 es7.math.fscale.js 11e3a9652a first 7 年之前 es7.math.iaddh.js 11e3a9652a first 7 年之前 es7.math.imulh.js 11e3a9652a first 7 年之前 es7.math.isubh.js 11e3a9652a first 7 年之前 es7.math.rad-per-deg.js 11e3a9652a first 7 年之前 es7.math.radians.js 11e3a9652a first 7 年之前 es7.math.scale.js 11e3a9652a first 7 年之前 es7.math.signbit.js 11e3a9652a first 7 年之前 es7.math.umulh.js 11e3a9652a first 7 年之前 es7.object.define-getter.js 11e3a9652a first 7 年之前 es7.object.define-setter.js 11e3a9652a first 7 年之前 es7.object.entries.js 11e3a9652a first 7 年之前 es7.object.get-own-property-descriptors.js 11e3a9652a first 7 年之前 es7.object.lookup-getter.js 11e3a9652a first 7 年之前 es7.object.lookup-setter.js 11e3a9652a first 7 年之前 es7.object.values.js 11e3a9652a first 7 年之前 es7.observable.js 11e3a9652a first 7 年之前 es7.promise.finally.js 11e3a9652a first 7 年之前 es7.promise.try.js 11e3a9652a first 7 年之前 es7.reflect.define-metadata.js 11e3a9652a first 7 年之前 es7.reflect.delete-metadata.js 11e3a9652a first 7 年之前 es7.reflect.get-metadata-keys.js 11e3a9652a first 7 年之前 es7.reflect.get-metadata.js 11e3a9652a first 7 年之前 es7.reflect.get-own-metadata-keys.js 11e3a9652a first 7 年之前 es7.reflect.get-own-metadata.js 11e3a9652a first 7 年之前 es7.reflect.has-metadata.js 11e3a9652a first 7 年之前 es7.reflect.has-own-metadata.js 11e3a9652a first 7 年之前 es7.reflect.metadata.js 11e3a9652a first 7 年之前 es7.set.from.js 11e3a9652a first 7 年之前 es7.set.of.js 11e3a9652a first 7 年之前 es7.set.to-json.js 11e3a9652a first 7 年之前 es7.string.at.js 11e3a9652a first 7 年之前 es7.string.match-all.js 11e3a9652a first 7 年之前 es7.string.pad-end.js 11e3a9652a first 7 年之前 es7.string.pad-start.js 11e3a9652a first 7 年之前 es7.string.trim-left.js 11e3a9652a first 7 年之前 es7.string.trim-right.js 11e3a9652a first 7 年之前 es7.symbol.async-iterator.js 11e3a9652a first 7 年之前 es7.symbol.observable.js 11e3a9652a first 7 年之前 es7.system.global.js 11e3a9652a first 7 年之前 es7.weak-map.from.js 11e3a9652a first 7 年之前 es7.weak-map.of.js 11e3a9652a first 7 年之前 es7.weak-set.from.js 11e3a9652a first 7 年之前 es7.weak-set.of.js 11e3a9652a first 7 年之前 web.dom.iterable.js 11e3a9652a first 7 年之前 web.immediate.js 11e3a9652a first 7 年之前 web.timers.js 11e3a9652a first 7 年之前 tamron - Gogs: Go Git Service

No Description

waterfull.js 2.7KB

    window.onload = function(){ var oParent = document.getElementById('main'); waterFall(oParent); window.onscroll = function(){ if(checkLoad()){ // 将数据渲染到页面里 for(var i=0; i<dataInt.data.length; i++){ var oBox = document.createElement('div'); oBox.className = 'box'; oParent.appendChild(oBox); var oPic = document.createElement('div'); oPic.className = 'pic'; oBox.appendChild(oPic); var oImg = document.createElement('img'); oImg.src = 'images/'+dataInt.data[i].src; oImg.style.cssText = 'transform: scale(0);'; oImg.onload = function(){ this.style.cssText = 'transform: scale(1);transition: transform 1s .5s;' } oPic.appendChild(oImg); } waterFall(oParent); } } window.onresize = function(){ waterFall(oParent); } } function waterFall(oParent){ var oBox = getClsName('box'); // 计算整个页面的列数 var oBoxW = oBox[0].offsetWidth; var paddingLeft = parseInt(getAttr(oBox[0],'paddingLeft')); var cols = Math.floor(document.documentElement.clientWidth / oBoxW); // 设置main的属性 oParent.style.cssText = 'width:'+oBoxW*cols+'px;margin:0 auto;left:'+(-paddingLeft/2)+'px'; // 存取每列的高度 var hArr = []; for(var i=0;i<oBox.length;i++){ if(i<cols){// 如果i < cols 说明是前六个box的高度 hArr.push(oBox[i].offsetHeight); oBox[i].style.cssText='position:absolute;top:0px;left:'+oBoxW*i+'px;'; }else{ // i>cols存取每列的高度 var minH = Math.min.apply(null,hArr); var index = getMinHIndex(hArr,minH); oBox[i].style.cssText='position:absolute;top:'+minH+'px;left:'+oBoxW*index+'px;'; hArr[index] += oBox[i].offsetHeight; } } } // 选择出class为box的 元素 function getClsName(cls){ var eles = document.getElementsByTagName('*'); var curEle = []; for(var i=0;i<eles.length;i++){ if(eles[i].className == cls){ curEle.push(eles[i]); } } return curEle; } // 获取元素的样式 function getAttr(obj,attr){ return window.getComputedStyle?window.getComputedStyle(obj,null)[attr]:obj.currentStyle[attr]; } // 获取最小值的索引 function getMinHIndex(arr,val){ for(var i in arr){ if(arr[i] == val){ return i; } } } // 检测是否具备加载条件 function checkLoad(){ var oBox = getClsName('box'); var lastBoxH = oBox[oBox.length-1].offsetTop; var scrollTop = document.body.scrollTop || document.documentElement.scrollTop; var pageH = document.body.clientHeight|| document.documentElement.clientHeight; return (lastBoxH < scrollTop + pageH)?true:false; // var lastBoxH = oBox[oBox.length-1].offsetTop+Math.floor(oBox[oBox.length-1].offsetTop/2); }