-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogFrame.js
29 lines (28 loc) · 903 Bytes
/
logFrame.js
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
var logBySelector = function (id) {
let elm = document.querySelector(id);
logFrame(elm);
elm.onscroll = function () {
logFrame(elm);
if (elm.scrollHeight - elm.scrollTop === elm.clientHeight) {
console.log('到底了');
}
else if (elm.scrollTop === 0) {
console.log('到顶了');
}
}
};
var logFrame = function (elm) {
console.log(elm, '-------------------------');
console.log(elm.getBoundingClientRect());
for (key in elm) {
let whiteList = [
'offsetTop', 'offsetLeft', 'offsetWidth', 'offsetHeight',
'scrollTop', 'scrollLeft', 'scrollWidth', 'scrollHeight',
'clientTop', 'clientLeft', 'clientWidth', 'clientHeight',
'offsetParent'
];
if (whiteList.indexOf(key) !== -1) {
console.log(key, ' = ', elm[key]);
}
}
}