Skip to content

Commit 3f7c5a9

Browse files
authored
Merge pull request #237 from BuildFire/fix-lazy-loading
Fix lazy loading
2 parents e89be49 + 7c44dad commit 3f7c5a9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

widget/directives.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@
6161
return {
6262
restrict: 'A',
6363
link: function (scope, element, attrs) {
64-
var raw = element[0];
64+
let raw = element[0], timeOut = null, timer = 300;
6565
element.on('scroll', function () {
66-
if (raw.scrollTop + raw.offsetHeight == raw.scrollHeight) { //at the bottom
67-
scope.$apply(attrs.scrolly);
66+
if (raw.scrollTop + raw.offsetHeight >= (raw.scrollHeight*0.60)) { //at the bottom
67+
clearTimeout(timeOut);
68+
timeOut = setTimeout(()=>{
69+
scope.$apply(attrs.scrolly);
70+
}, timer)
6871
}
6972
})
7073
}

0 commit comments

Comments
 (0)