Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / third_party / pycoverage / coverage / htmlfiles / jquery.isonscreen.js
blob0182ebd21372e5f84fa0aeb6d7c10f9f724002da
1 /* Copyright (c) 2010
2 * @author Laurence Wheway
3 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
4 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
6 * @version 1.2.0
7 */
8 (function($) {
9 jQuery.extend({
10 isOnScreen: function(box, container) {
11 //ensure numbers come in as intgers (not strings) and remove 'px' is it's there
12 for(var i in box){box[i] = parseFloat(box[i])};
13 for(var i in container){container[i] = parseFloat(container[i])};
15 if(!container){
16 container = {
17 left: $(window).scrollLeft(),
18 top: $(window).scrollTop(),
19 width: $(window).width(),
20 height: $(window).height()
24 if( box.left+box.width-container.left > 0 &&
25 box.left < container.width+container.left &&
26 box.top+box.height-container.top > 0 &&
27 box.top < container.height+container.top
28 ) return true;
29 return false;
34 jQuery.fn.isOnScreen = function (container) {
35 for(var i in container){container[i] = parseFloat(container[i])};
37 if(!container){
38 container = {
39 left: $(window).scrollLeft(),
40 top: $(window).scrollTop(),
41 width: $(window).width(),
42 height: $(window).height()
46 if( $(this).offset().left+$(this).width()-container.left > 0 &&
47 $(this).offset().left < container.width+container.left &&
48 $(this).offset().top+$(this).height()-container.top > 0 &&
49 $(this).offset().top < container.height+container.top
50 ) return true;
51 return false;
53 })(jQuery);