Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middle-mouse click & scroll icon is offset #134

Closed
derekpock opened this issue Jun 7, 2016 · 2 comments
Closed

Middle-mouse click & scroll icon is offset #134

derekpock opened this issue Jun 7, 2016 · 2 comments

Comments

@derekpock
Copy link

derekpock commented Jun 7, 2016

The scroll indicator is not where it should be when middle clicking on Chrome on Ubuntu 16.04.

Note, in the screenshots below, I simply middle-clicked and that is where the indicator cursor showed up. I did not move my mouse after middle-clicking. No scrolling happened (without moving the mouse), and the middle-click scroll icon is offset from where I clicked.

screenshot from 2016-06-06 19-23-51
screenshot from 2016-06-06 19-23-36

@mohkamfer
Copy link

mohkamfer commented Sep 10, 2016

I believe this is an issue with DOM elements having zoom set to something other than 1.
I made some testing and this is the quick fix for it:

(function() {
    $(window).on('DOMNodeInserted', function(){
        var divs = document.getElementsByTagName('div');
        for (var i = 0; i < divs.length; ++i) {
            if ((document.getElementsByTagName('div')[i].style.width === '20px') && (document.getElementsByTagName('div')[i].style.height === '20px')) {
                console.log('child index: ' + i);
                var currentElement = document.getElementsByTagName('div')[i];
                var currentTop = currentElement.style.top;
                var currentLeft = currentElement.style.left;
                var currentPageZoom = Number(document.getElementsByTagName('body')[0].style.zoom);
                console.log(currentPageZoom);
                if (currentPageZoom === 0) {
                    currentPageZoom = Number(document.getElementsByTagName('html')[0].style.zoom);
                }
                console.log(currentPageZoom);
                //console.log('Scroll cursor detected!');
                console.log("MMB    at " + currentTop + " " + currentLeft);
                console.log('Cursor at ' + currentElement.style.top + " " + currentElement.style.left);
                currentElement.style.top = injectPx(parseInt(currentTop, 10) / currentPageZoom);
                currentElement.style.left = injectPx(parseInt(currentLeft, 10) / currentPageZoom);
                console.log('Cursor at ' + currentElement.style.top + " " + currentElement.style.left);
            }
        }
    });
} ) ();

function injectPx(number) {
    return  + number + 'px';
}

Note that this isn't what's gonna be inserted in the actual source code, this is just a work around I use via a JS code injecting solution that you can get from Chrome Store (like Tampermonkey, etc...)

EDIT: Also you can comment out the debug logs if it's annoying, I just got that snippet to work and didn't even bother revising it :D

@gblazex
Copy link
Owner

gblazex commented Oct 22, 2019

which os? it works fine for me

@gblazex gblazex closed this as completed Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants