feature(dom) scrollIntViewIfNeeded: add second param

This commit is contained in:
coderaiser 2014-01-21 05:59:51 -05:00
parent 23f61acfb9
commit 8b42f0a659
2 changed files with 12 additions and 3 deletions

View file

@ -1767,12 +1767,19 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
* unified way to scrollIntoViewIfNeeded
* (native suporte by webkit only)
* @param pElement
* @param pCenter
*/
this.scrollIntoViewIfNeeded = function(pElement) {
this.scrollIntoViewIfNeeded = function(pElement, pCenter) {
var lRet = pElement && pElement.scrollIntoViewIfNeeded;
/* for scroll as small as possible
* param should be false
*/
if (arguments.length === 1)
pCenter = false;
if (lRet)
pElement.scrollIntoViewIfNeeded(false);
pElement.scrollIntoViewIfNeeded(pCenter);
return lRet;
};

View file

@ -107,7 +107,9 @@ var Util, DOM, jQuery;
alignWithTop;
if (window.getComputedStyle) {
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
if (arguments.length === 1)
centerIfNeeded = false;
parent = pElement.parentNode;
parentComputedStyle = window.getComputedStyle(parent, null);