Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Commit

Permalink
JasonLeyba on behalf of KenKania: Creating a new atom to retrieve the…
Browse files Browse the repository at this point in the history
… location of an element, relative to the client viewport, once it has been scrolled into view.

r11522
  • Loading branch information
jleyba committed Feb 23, 2011
1 parent b6db2af commit a4aa488
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions javascript/atoms/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,16 @@ bot.dom.getOpacityNonIE_ = function(elem) {
}
return elemOpacity;
};


/**
* Scrolls the element into the client's view and returns its position
* relative to the client viewport.
*
* @param {!Element} element The element to use.
* @param {!goog.math.Coordinate} The coordinate of the element.
*/
bot.dom.getLocationInView = function(element) {
element.scrollIntoView();
return goog.style.getClientPosition();
};
1 change: 1 addition & 0 deletions javascript/chrome-driver/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ js_fragment_header(name = "atoms",
"//javascript/webdriver-atoms:get_attribute",
"//javascript/webdriver-atoms:get_effective_style",
"//javascript/webdriver-atoms:get_location",
"//javascript/webdriver-atoms:get_location_in_view",
"//javascript/webdriver-atoms:get_size",
"//javascript/webdriver-atoms:get_text",
"//javascript/webdriver-atoms:is_displayed",
Expand Down
5 changes: 5 additions & 0 deletions javascript/webdriver-atoms/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ js_fragment(name = "get_location",
function = "goog.style.getPageOffset",
deps = [ "//javascript/atoms:deps" ])

js_fragment(name = "get_location_in_view",
module = "bot.dom",
function = "bot.dom.getLocationInView",
deps = [ "//javascript/atoms:deps" ])

# TODO(simon): I'm not convinced this is right
js_fragment(name = "get_size",
module = "goog.style",
Expand Down

0 comments on commit a4aa488

Please sign in to comment.