File tree 1 file changed +12
-11
lines changed 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -95,23 +95,24 @@ function rewireLoggingToElement(
95
95
const prefix = '[<span class="log-' + name + '">' + id + "</span>]: "
96
96
const eleContainerLog = eleOverflowLocator ( )
97
97
allLogs = allLogs + prefix + output + "<br>"
98
-
99
- if ( eleLog && eleContainerLog ) {
100
- if ( autoScroll ) {
101
- const atBottom = eleContainerLog . scrollHeight - eleContainerLog . clientHeight <= eleContainerLog . scrollTop + 1
102
- eleLog . innerHTML = allLogs
103
-
104
- if ( atBottom ) eleContainerLog . scrollTop = eleContainerLog . scrollHeight - eleContainerLog . clientHeight
105
- } else {
106
- eleLog . innerHTML = allLogs
107
- }
98
+ eleLog . innerHTML = allLogs
99
+ const scrollElement = eleContainerLog . parentElement
100
+ if ( autoScroll && scrollElement ) {
101
+ scrollToBottom ( scrollElement )
108
102
}
109
-
110
103
// @ts -ignore
111
104
console [ "old" + name ] . apply ( undefined , objs )
112
105
}
113
106
}
114
107
108
+ function scrollToBottom ( element : Element ) {
109
+ const overflowHeight = element . scrollHeight - element . clientHeight
110
+ const atBottom = element . scrollTop >= overflowHeight
111
+ if ( ! atBottom ) {
112
+ element . scrollTop = overflowHeight
113
+ }
114
+ }
115
+
115
116
function produceOutput ( args : any [ ] ) {
116
117
return args . reduce ( ( output : any , arg : any , index ) => {
117
118
const isObj = typeof arg === "object"
You can’t perform that action at this time.
0 commit comments