-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollHelper.js
More file actions
94 lines (91 loc) · 2.09 KB
/
scrollHelper.js
File metadata and controls
94 lines (91 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Scroll helper is a solution that tries to scroll down
* the DOMElement again and again until the last record.
*
*
**/
/**
* @param {DOMElement}
* @param {string} //{str}
**/
const ScrollerHelperClass = function(holder_, list_element_){
/** @type {DOMElement} **/
const _e = holder_;
/** @type {string}//{str} **/
const _list_element = list_element_;
/** @type {number} //{uint16_t} **/
let _length = document.querySelectorAll(_list_element).length;
let _resolve = (it)=>{console.log(it)};
/** @type {number} //{uint16_t} **/
let _sVal = 0;
const _mT = new MinerToolClass('scroll', 4000, 2000);
const _setRandOut = _mT.setRandOut;
const _log = _mT.log;
const _cH = new CoolHelperClass();
/**
*
* @private
**/
const _check = function(){
_e.scroll(0,0);
_setRandOut(function(){
const length = document.querySelectorAll(_list_element).length;
_log(
'check',
(
'Size : '+
length.toString()+
' '+
_length.toString()
)
);
if ( length === _length ){
_log(
'check','done'
);
return _resolve(true);
}
_length = length;
_setRandOut(_again);
});
}
/**
*
* @private
**/
const _do = async function(){
await _cH.scroll();
_sVal += (
10000 + Math.round(
Math.random() * 20000
)
);
_e.scroll(0,_sVal);
_setRandOut(_check);
}
/**
*
* @private
**/
const _again = function (){
_setRandOut(_do);
};
/**
*
* @public
**/
this.scroll = function(){
_log(
'start',
(
'Size : '+
_length.toString()
)
);
const scr = this;
return new Promise(function (resolve, reject) {
_resolve = resolve;
_setRandOut(_do);
});
}
}