Function cleanup

This commit is contained in:
mattpass
2020-03-07 09:33:26 +00:00
parent 05ddbf33ef
commit 677c9eee87

View File

@@ -1538,24 +1538,28 @@ var ICEcoder = {
var cM, mmPosY;
if (ICEcoder.mouseDownMinimap) {
// console.log(Date.now() - ICEcoder.lastScrollTS);
cM = this.getcMInstance();
// Set mid height position
mmPosY = e.y - get('miniMapContainer').getBoundingClientRect().top - (get('miniMapBox').getBoundingClientRect().height / 2);
// Unless it would be beyond bottom, if so, set to bottom
if (mmPosY > get('miniMapContainer').getBoundingClientRect().height - get('miniMapBox').getBoundingClientRect().height) {
// console.log("YES");
mmPosY = get('miniMapContainer').getBoundingClientRect().height - get('miniMapBox').getBoundingClientRect().height;
}
// Unless it would be beyond top, if so, set to top
if (mmPosY < 0) {
mmPosY = 0;
}
get("miniMapBox").style.top = mmPosY + "px";
maxHeight = parseInt(get('docExplorer').style.height, 10) <= parseInt(get('miniMapContainer').getBoundingClientRect().height, 10)
// Set the max height to be that of doc explorer, or if less, the content height
maxHeight = parseInt(get('docExplorer').style.height, 10) <= parseInt(get('miniMapContent').getBoundingClientRect().height, 10)
? parseInt(get('docExplorer').style.height, 10)
: parseInt(get('miniMapContainer').getBoundingClientRect().height, 10);
: parseInt(get('miniMapContent').getBoundingClientRect().height, 10);
// Work out the new percentag, from that yPos and set CM scroll position to that
newPerc = (mmPosY / (maxHeight - ICEcoder.miniMapBoxHeight));
yPos = (cM.getScrollInfo().height - cM.getScrollInfo().clientHeight) * newPerc;
cM.scrollTo(0, yPos); // this.position.y
}
// If mouse buttons up, we no longer have mouse down on minimap
if (e.buttons === 0) {
ICEcoder.mouseDownMinimap = false;
}