|
88 | 88 | default: 0 |
89 | 89 | }, |
90 | 90 | totop: { |
91 | | - type: [Function, Boolean], // Boolean just disable for priviate. |
| 91 | + type: [Function, Boolean], |
92 | 92 | default: false |
93 | 93 | }, |
94 | 94 | tobottom: { |
95 | | - type: [Function, Boolean], // Boolean just disable for priviate. |
| 95 | + type: [Function, Boolean], |
96 | 96 | default: false |
97 | 97 | }, |
98 | 98 | onscroll: { |
99 | | - type: [Function, Boolean], // Boolean just disable for priviate. |
| 99 | + type: [Function, Boolean], // Boolean disables default behavior |
100 | 100 | default: false |
101 | 101 | }, |
102 | 102 | istable: { |
|
118 | 118 | } |
119 | 119 | }, |
120 | 120 |
|
121 | | - // use changeProp to identify which prop change. |
| 121 | + // use changeProp to identify the prop change. |
122 | 122 | watch: { |
123 | 123 | size () { |
124 | 124 | this.changeProp = 'size' |
|
303 | 303 | const zone = this.getZone(overs) |
304 | 304 | const bench = this.bench || this.remain |
305 | 305 |
|
306 | | - // for better performance, if scroll pass items within now bench, do not update. |
307 | | - // and if overs is going to reach last item, we should render next zone immediately. |
| 306 | + // for better performance, if scroll passes items within the bench, do not update. |
| 307 | + // and if it's close to the last item, render next zone immediately. |
308 | 308 | const shouldRenderNextZone = Math.abs(overs - delta.start - bench) === 1 |
309 | 309 | if ( |
310 | 310 | !shouldRenderNextZone && |
|
314 | 314 | return |
315 | 315 | } |
316 | 316 |
|
317 | | - // we'd better make sure forceRender calls as less as possible. |
| 317 | + // make sure forceRender calls as less as possible. |
318 | 318 | if ( |
319 | 319 | shouldRenderNextZone || |
320 | 320 | zone.start !== delta.start || |
|
326 | 326 | } |
327 | 327 | }, |
328 | 328 |
|
329 | | - // return the right zone info base on `start/index`. |
| 329 | + // return the right zone info based on `start/index`. |
330 | 330 | getZone (index) { |
331 | 331 | let start |
332 | 332 | const delta = this.delta |
|
350 | 350 | } |
351 | 351 | }, |
352 | 352 |
|
353 | | - // public method, force render ui list if we needed. |
354 | | - // call this before the next repaint to get better performance. |
| 353 | + // public method, force render ui list if needed. |
| 354 | + // call this before the next rerender to get better performance. |
355 | 355 | forceRender () { |
356 | 356 | window.requestAnimationFrame(() => { |
357 | 357 | this.$forceUpdate() |
|
365 | 365 | } |
366 | 366 | }, |
367 | 367 |
|
368 | | - // return the scroll passed items count in variable. |
| 368 | + // return the scroll of passed items count in variable. |
369 | 369 | getVarOvers (offset) { |
370 | 370 | let low = 0 |
371 | 371 | let middle = 0 |
|
444 | 444 | return 0 |
445 | 445 | }, |
446 | 446 |
|
447 | | - // return the variable paddingTop base current zone. |
| 447 | + // return the variable paddingTop based on current zone. |
448 | 448 | // @todo: if set a large `start` before variable was calculated, |
449 | 449 | // here will also case too much offset calculate when list is very large, |
450 | 450 | // consider use estimate paddingTop in this case just like `getVarPaddingBottom`. |
451 | 451 | getVarPaddingTop () { |
452 | 452 | return this.getVarOffset(this.delta.start) |
453 | 453 | }, |
454 | 454 |
|
455 | | - // return the variable paddingBottom base current zone. |
| 455 | + // return the variable paddingBottom based on the current zone. |
456 | 456 | getVarPaddingBottom () { |
457 | 457 | const delta = this.delta |
458 | 458 | const last = delta.total - 1 |
459 | 459 | if (delta.total - delta.end <= delta.keeps || delta.varLastCalcIndex === last) { |
460 | 460 | return this.getVarOffset(last) - this.getVarOffset(delta.end) |
461 | 461 | } else { |
462 | | - // if unreached last zone or uncalculate real behind offset |
463 | | - // return the estimate paddingBottom avoid too much calculate. |
| 462 | + // if unreached last zone or uncalculated real behind offset |
| 463 | + // return the estimate paddingBottom and avoid too much calculations. |
464 | 464 | return (delta.total - delta.end) * (delta.varAverSize || this.size) |
465 | 465 | } |
466 | 466 | }, |
467 | 467 |
|
468 | | - // retun the variable all heights use to judge reach bottom. |
| 468 | + // return the variable all heights use to judge reach bottom. |
469 | 469 | getVarAllHeight () { |
470 | 470 | const delta = this.delta |
471 | 471 | if (delta.total - delta.end <= delta.keeps || delta.varLastCalcIndex === delta.total - 1) { |
|
477 | 477 |
|
478 | 478 | // public method, allow the parent update variable by index. |
479 | 479 | updateVariable (index) { |
480 | | - // clear/update all the offfsets and heights ahead of index. |
| 480 | + // clear/update all the offsets and heights ahead of index. |
481 | 481 | this.getVarOffset(index, true) |
482 | 482 | }, |
483 | 483 |
|
|
502 | 502 | } |
503 | 503 | }, |
504 | 504 |
|
505 | | - // filter the shown items base on `start` and `end`. |
| 505 | + // filter the shown items based on `start` and `end`. |
506 | 506 | filter (h) { |
507 | 507 | const delta = this.delta |
508 | 508 | const slots = this.$slots.default || [] |
509 | 509 |
|
510 | | - // item-mode shoud judge from items prop. |
| 510 | + // item-mode should be decided from items prop. |
511 | 511 | if (this.item || this.$scopedSlots.item) { |
512 | 512 | delta.total = this.itemcount |
513 | 513 | if (delta.keeps > delta.total) { |
|
573 | 573 | style: { |
574 | 574 | display: 'block', |
575 | 575 | 'padding-top': paddingTop + 'px', |
576 | | - 'padding-bottom': paddingBottom + 'px' |
| 576 | + 'padding-bottom': paddingBottom + 'px', |
577 | 577 | }, |
578 | 578 | class: this.wclass, |
579 | 579 | attrs: { |
580 | 580 | role: 'group' |
581 | 581 | } |
582 | 582 | }, list) |
583 | 583 |
|
584 | | - // page mode just render list, no wraper. |
| 584 | + // page mode just render list, no wrapper. |
585 | 585 | if (this.pagemode || this.scrollelement) { |
586 | 586 | return renderList |
587 | 587 | } |
|
590 | 590 | ref: 'vsl', |
591 | 591 | style: { |
592 | 592 | display: 'block', |
593 | | - 'overflow-y': this.size >= this.remain ? 'auto' : 'inital', |
| 593 | + 'overflow-y': this.size >= this.remain ? 'auto' : 'initial', |
594 | 594 | height: this.size * this.remain + 'px' |
595 | 595 | }, |
596 | 596 | on: { |
|
0 commit comments