Type-To-Navigate icon indicating copy to clipboard operation
Type-To-Navigate copied to clipboard

Search only visible links

Open franciscolourenco opened this issue 14 years ago • 6 comments

Give priority to links which are inside the visible area.

Only search the entire page, if there are no visible link which match the criteria or while iterating with ⌘G/⌘⇧G.

franciscolourenco avatar Jul 30 '11 12:07 franciscolourenco

Agreed, this should be an improvement.

dbergey avatar Jan 06 '12 01:01 dbergey

I'd love this. I had a look at the relevant code, which I'm guessing is injection.js, but it seemed quite stateful and so I wouldn't trust myself to modify it correctly. It seems to this could be done very easily, by testing whether elements are in the part of the document currently seen by the user. document.body.scrollTop and document.body.scrollLeft give the current X and Y offsets of where the user is in the document. (They even adjust correctly when zoomed in, unlike window.page{X,Y}offset). To get each element's position, you can ask for its .offsetTop and .offsetLeft, e.g.:

document.querySelector("a").offsetLeft

So, we can compare the element positions with the screen position and only select elements which are below and to the right of the user's screen, defaulting to the old behaviour only when no such elements are found.

ghost avatar Mar 18 '12 20:03 ghost

Yep, that's the way I'd do it. Maybe I'll give it a go this evening or next.

Sent from my iPhone 5

On Mar 18, 2012, at 4:03 PM, Marius Kempe [email protected] wrote:

I'd love this. I had a look at the relevant code, which I'm guessing is injection.js, but it seemed quite stateful and so I wouldn't trust myself to modify it correctly. It seems to this could be done very easily, by testing whether elements are in currently seen by the user. document.body.scrollTop and document.body.scrollLeft give the current X and Y offsets of where the user is in the document. (They even adjust correctly when zoomed in, unlike window.page{X,Y}offset). To get each elements position, you can ask for its .offsetTop and .offsetLeft, e.g.:

document.querySelector("a").offsetLeft

So that, we can compare the element positions with the screen position and only select elements which are below and to the right of the user's screen, defaulting to the old behaviour only when no such elements are found.


Reply to this email directly or view it on GitHub: https://github.com/dbergey/Type-To-Navigate/issues/5#issuecomment-4563916

dbergey avatar Mar 18 '12 20:03 dbergey

Thanks!

PS. Your iPhone 5? ;-)

On 18 Mar 2012, at 8:04PM, Daniel Bergey wrote:

Yep, that's the way I'd do it. Maybe I'll give it a go this evening or next.

Sent from my iPhone 5

On Mar 18, 2012, at 4:03 PM, Marius Kempe [email protected] wrote:

I'd love this. I had a look at the relevant code, which I'm guessing is injection.js, but it seemed quite stateful and so I wouldn't trust myself to modify it correctly. It seems to this could be done very easily, by testing whether elements are in currently seen by the user. document.body.scrollTop and document.body.scrollLeft give the current X and Y offsets of where the user is in the document. (They even adjust correctly when zoomed in, unlike window.page{X,Y}offset). To get each elements position, you can ask for its .offsetTop and .offsetLeft, e.g.:

document.querySelector("a").offsetLeft

So that, we can compare the element positions with the screen position and only select elements which are below and to the right of the user's screen, defaulting to the old behaviour only when no such elements are found.


Reply to this email directly or view it on GitHub: https://github.com/dbergey/Type-To-Navigate/issues/5#issuecomment-4563916


Reply to this email directly or view it on GitHub: https://github.com/dbergey/Type-To-Navigate/issues/5#issuecomment-4563934

ghost avatar Mar 18 '12 20:03 ghost

You're the first person to notice that.

Sent from my iPhone 5

On Mar 18, 2012, at 4:06 PM, Marius Kempe [email protected] wrote:

Thanks!

PS. Your iPhone 5? ;-)

On 18 Mar 2012, at 8:04PM, Daniel Bergey wrote:

Yep, that's the way I'd do it. Maybe I'll give it a go this evening or next.

Sent from my iPhone 5

On Mar 18, 2012, at 4:03 PM, Marius Kempe [email protected] wrote:

I'd love this. I had a look at the relevant code, which I'm guessing is injection.js, but it seemed quite stateful and so I wouldn't trust myself to modify it correctly. It seems to this could be done very easily, by testing whether elements are in currently seen by the user. document.body.scrollTop and document.body.scrollLeft give the current X and Y offsets of where the user is in the document. (They even adjust correctly when zoomed in, unlike window.page{X,Y}offset). To get each elements position, you can ask for its .offsetTop and .offsetLeft, e.g.:

document.querySelector("a").offsetLeft

So that, we can compare the element positions with the screen position and only select elements which are below and to the right of the user's screen, defaulting to the old behaviour only when no such elements are found.


Reply to this email directly or view it on GitHub: https://github.com/dbergey/Type-To-Navigate/issues/5#issuecomment-4563916


Reply to this email directly or view it on GitHub: https://github.com/dbergey/Type-To-Navigate/issues/5#issuecomment-4563934


Reply to this email directly or view it on GitHub: https://github.com/dbergey/Type-To-Navigate/issues/5#issuecomment-4563947

dbergey avatar Mar 18 '12 20:03 dbergey

ahah

franciscolourenco avatar Mar 18 '12 20:03 franciscolourenco