Skip to content

schmidt/jquery.onscreen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

jQuery.onscreen Plugin

This plugin adds a :onscreen pseudo selector to the list of jQuery selectors. You may use it to test, if an partially visible on the screen.

Examples

Focus the first visible input element:

$("input:onscreen").first().focus()

Scroll element into view if it was not visible before

e = $("#calltoaction")

if (!e.is(":onscreen")) {
    e.get(0).scrollIntoView();
}

Future work

  • Add tests
  • Add :fullyonscreen which would match if the whole element is on the screen, not just parts of it.

Copyright

This code is just a wrapped version of a StackOverflow answer published on jsfiddle.

Here are the relevant sources:

Author:
pebbl http://pebbl.co.uk/
StackOverflow:
http://stackoverflow.com/q/487073/817202#comment41045330_21627295
JSFiddle:
http://jsfiddle.net/9nuqpgqa/

About

jQuery plugin which adds an :onscreen pseudo selector

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published