8
8
position : absolute ;
9
9
top : 100% ;
10
10
left : 100% ;
11
+ width : 0 ;
12
+ height : 0 ;
13
+ overflow : hidden ;
11
14
}
12
15
.vue-waterfall .vue-waterfall-column {
13
16
float : left ;
@@ -107,7 +110,6 @@ import bus from './bus'
107
110
})
108
111
},
109
112
data (newVal ,oldVal ){
110
-
111
113
this .$nextTick (()=> {
112
114
clearTimeout (this .timer )
113
115
this .timer = setTimeout (()=> {
@@ -119,13 +121,10 @@ import bus from './bus'
119
121
{
120
122
this .loadedIndex = 0
121
123
}
122
- // console.log(newVal.length,oldVal.length,newVal.length,this.loadedIndex)
123
124
if (newVal .length > oldVal .length || newVal .length > this .loadedIndex )
124
125
{
125
-
126
126
if (newVal .length === oldVal .length )
127
127
{
128
- // console.log(this.loadedIndex)
129
128
this .resize (this .loadedIndex > 0 ? this .loadedIndex : null )
130
129
return
131
130
}
@@ -171,7 +170,6 @@ import bus from './bus'
171
170
for (var i= 0 ;i< imgs .length ;i++ )
172
171
{
173
172
var lazySrc = imgs[i].getAttribute (' lazy-src' )
174
- // console.log(lazySrc)
175
173
if (! imgs[i].getAttribute (' src' )&& lazySrc)
176
174
{
177
175
var newImg = new Image ()
@@ -212,9 +210,7 @@ import bus from './bus'
212
210
if (this .columns .length > 0 )
213
211
{
214
212
let min = this .columns [0 ]
215
- // await new Promise(async (resolve,reject)=>{
216
213
for (var i= 1 ;i< this .columns .length ;i++ ){
217
- // console.log('---')
218
214
if (await self .getHeight (min)> await self .getHeight (self .columns [i])){
219
215
min = self .columns [i]
220
216
}
@@ -254,30 +250,22 @@ import bus from './bus'
254
250
elements = this .$slots .default .splice (index)
255
251
}
256
252
257
- // console.log('resize',elements.length)
258
253
for (var j= 0 ;j< elements .length ;j++ ){
259
- // (async function(j){
260
- // console.log(j)
261
254
if (elements[j].elm && self .checkImg (elements[j].elm ))
262
255
{
263
- // console.log(elements[j].elm)
264
256
var imgs = elements[j].elm .getElementsByTagName (' img' )
265
257
var newImg = new Image ()
266
258
newImg .src = imgs[0 ].src
267
- // self.lazyLoad(imgs)
268
-
269
259
if (newImg .complete )
270
260
{
271
- // self.computedPx(imgs[0],newImg)
272
261
await self .append (elements[j].elm )
273
- self .lazyLoad (imgs)
262
+ self .lazyLoad (imgs)
274
263
}
275
264
else {
276
265
await new Promise ( (resolve ,reject )=> {
277
266
newImg .onload = async function (){
278
267
await self .append (elements[j].elm )
279
268
self .lazyLoad (imgs)
280
- // console.log('loaded')
281
269
resolve ()
282
270
}
283
271
newImg .onerror = async function (){
@@ -286,16 +274,13 @@ import bus from './bus'
286
274
resolve ()
287
275
}
288
276
})
289
- // console.log(j)
290
277
}
291
278
292
279
}
293
280
else {
294
281
await self .append (elements[j].elm )
295
- // console.log('append')
296
282
}
297
283
self .loadedIndex ++
298
- // })(i)
299
284
}
300
285
this .isresizing = false
301
286
self .$emit (' finish' )
@@ -305,9 +290,7 @@ import bus from './bus'
305
290
306
291
img .style .width = imgApi .width / this .columnWidth
307
292
},
308
- lazyLoad (imgs ){ //
309
- // console.log(123)
310
- // console.log('lazy-load')
293
+ lazyLoad (imgs ){
311
294
if (! imgs)
312
295
{
313
296
if (! this .root )
@@ -325,20 +308,6 @@ import bus from './bus'
325
308
}
326
309
for (var index= 0 ;index< imgs .length ; index++ )
327
310
{
328
- // if(imgs[index].className.match('animation')&&imgs[index].getAttribute('src'))
329
- // {
330
- // continue
331
- // }
332
- // if(!imgs[index].getAttribute('src')&&imgs[index].getBoundingClientRect().top<this.clientHeight+this.trueLazyDistance)
333
- // {
334
- // imgs[index].src = imgs[index].getAttribute('lazy-src')
335
- // imgs[index].className = imgs[index].className + ' animation'
336
- // // imgs[index].removeAttribute('lazy-src')
337
- // }
338
- // else if(imgs[index].getAttribute('src')&&!imgs[index].className.match('animation')){
339
- // imgs[index].className = imgs[index].className + ' animation'
340
- // }
341
-
342
311
if (imgs[index].className .match (' animation' )&& imgs[index].getAttribute (' src' ))
343
312
{
344
313
continue
@@ -379,47 +348,6 @@ import bus from './bus'
379
348
this .resize (0 ,elements)
380
349
},
381
350
async getHeight (dom ){
382
- // var flag = false
383
- // var imgs = dom.querySelectorAll('img')
384
- // var imgHeight = 0
385
- // for(var i=0;i<imgs.length;i++)
386
- // {
387
- // var lazySrc = imgs[i].getAttribute('lazy-src')
388
- // if(!imgs[i].getAttribute('src')&&lazySrc)
389
- // {
390
- // flag = true
391
- // var newImg = new Image()
392
- // newImg.src = lazySrc
393
- // if(newImg.complete)
394
- // {
395
- // var trueWidth = imgs[i].offsetWidth || this.columnWidth
396
- // var imgColumnHeight = newImg.height*trueWidth/newImg.width
397
- // imgHeight += newImg.height
398
- // if(imgs[i].offsetWidth)
399
- // {
400
- // imgs[i].style.height = imgColumnHeight+'px'
401
- // }
402
- // }
403
- // else{
404
- // await new Promise((resolve,reject)=>{
405
- // newImg.onload = function(){
406
- // var trueWidth = imgs[i].offsetWidth || this.columnWidth
407
- // var imgColumnHeight = newImg.height*trueWidth/newImg.width
408
- // imgHeight += newImg.height
409
- // if(imgs[i].offsetWidth)
410
- // {
411
- // imgs[i].style.height = imgColumnHeight+'px'
412
- // }
413
- // resolve()
414
- // }
415
- // newImg.onerror= function(){
416
- // imgHeight += 100
417
- // resolve()
418
- // }
419
- // })
420
- // }
421
- // }
422
- // }
423
351
return dom .offsetHeight
424
352
},
425
353
emitLoadMore (){
@@ -432,7 +360,6 @@ import bus from './bus'
432
360
const scrollHeight = this .root .scrollHeight
433
361
var diff = scrollHeight - scrollTop - self .clientHeight
434
362
self .$emit (' scroll' ,{scrollHeight: scrollHeight,scrollTop: scrollTop,clientHeight: self .clientHeight ,diff: diff,time: Date .now ()})
435
- console .log (diff,scrollHeight,scrollTop,self .clientHeight )
436
363
if (diff < self .max && self .loadmore && scrollHeight> self .clientHeight ){
437
364
self .lastScrollTop = scrollTop
438
365
self .loadmore = false
0 commit comments