diff options
author | amy <[email protected]> | 2023-02-23 15:20:17 +0000 |
---|---|---|
committer | amy <[email protected]> | 2023-02-23 15:20:17 +0000 |
commit | 279ed3d59493d2192df2fd7c797a494c8d713a53 (patch) | |
tree | 1a200d1780d006d760730a3d4cca1006e64619f0 /src | |
parent | 1bb422555e58b25cef388b85304a4cb6c58ee92d (diff) |
swapped old scrollbars
Diffstat (limited to 'src')
-rw-r--r-- | src/common.js | 22 | ||||
-rw-r--r-- | src/window-utils.js | 9 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/common.js b/src/common.js new file mode 100644 index 0000000..5606706 --- /dev/null +++ b/src/common.js @@ -0,0 +1,22 @@ +Object.prototype.clone = Array.prototype.clone = function() //https://stackoverflow.com/questions/12690107/clone-object-without-reference-javascript +{ + if (Object.prototype.toString.call(this) === '[object Array]') + { + var clone = []; + for (var i=0; i<this.length; i++) + clone[i] = this[i].clone(); + + return clone; + } + else if (typeof(this)=="object") + { + var clone = {}; + for (var prop in this) + if (this.hasOwnProperty(prop)) + clone[prop] = this[prop].clone(); + + return clone; + } + else + return this; +}
\ No newline at end of file diff --git a/src/window-utils.js b/src/window-utils.js index f45dd0f..149b9d0 100644 --- a/src/window-utils.js +++ b/src/window-utils.js @@ -21,13 +21,14 @@ let util = { //target is where the scrollbar will be placed, this element should be //larger than the root with scrollable overflow let scrolling = false - if(!procs[uid]) + if(undefined==procs[uid]) procs[uid] = {} target.innerHTML += "<div id='" + uid + "-" + minor_uid + "-content-scrollbar' class='scrollbar'><div id='" + uid + "-" + minor_uid + "-content-scrollbar-point' class='scrollbar-point'></div></div>" let thi_point = document.getElementById(uid + "-" + minor_uid + "-content-scrollbar-point") let thi_base = document.getElementById(uid + "-" + minor_uid + "-content-scrollbar") procs[uid].refresh = ()=>{ - console.log(root.clientHeight / (target.clientHeight / root.clientHeight) / root.clientHeight) + + //console.log(root.clientHeight / (target.clientHeight / root.clientHeight) / root.clientHeight) thi_point.style.display = "block" thi_base.style.display = "block" thi_point.style.height = root.clientHeight / (target.clientHeight / root.clientHeight) @@ -35,6 +36,10 @@ let util = { thi_point.style.display = "none" thi_base.style.display = "none" } + + if(thi_base.clientHeight<thi_point.offsetTop+thi_point.clientHeight){ + thi_point.style.top = thi_base.clientHeight-thi_point.clientHeight + } } console.log(root) root.onscroll = () => { |