dbergey / Type-To-Navigate

Keep your hands on the keyboard while browsing the web. Type any text that occurs inside a link, and hit return to follow it. ⌘G jumps to the next link containing the text, and ⌘⇧G jumps to the previous. Hit ESC to cancel or exit a focused field.
33 stars 9 forks source link

Search only visible links #5

Open franciscolourenco opened 13 years ago

franciscolourenco commented 13 years ago

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.

dbergey commented 12 years ago

Agreed, this should be an improvement.

ghost commented 12 years ago

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.

dbergey commented 12 years ago

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 reply@reply.github.com 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

ghost commented 12 years ago

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 reply@reply.github.com 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

dbergey commented 12 years ago

You're the first person to notice that.

Sent from my iPhone 5

On Mar 18, 2012, at 4:06 PM, Marius Kempe reply@reply.github.com 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 reply@reply.github.com 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

franciscolourenco commented 12 years ago

ahah