Skip to content

Commit

Permalink
Merge pull request #41 from PolymerElements/rictic-patch-1
Browse files Browse the repository at this point in the history
Improve type safety of scroll method
  • Loading branch information
keanulee authored Apr 13, 2018
2 parents c36cc42 + efaf4f5 commit f710846
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion iron-scroll-target-behavior.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ declare namespace Polymer {
* @param leftOrOptions The left position or scroll options
* @param top The top position
*/
scroll(leftOrOptions: number|ScrollToOptions, top?: number): void;
scroll(leftOrOptions: number|{left: number, top: number}, top?: number): void;

/**
* Returns true if the scroll target is a valid HTMLElement.
Expand Down
8 changes: 6 additions & 2 deletions iron-scroll-target-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,22 @@
* Scrolls the content to a particular place.
*
* @method scroll
* @param {number|!ScrollToOptions} leftOrOptions The left position or scroll options
* @param {number|!{left: number, top: number}} leftOrOptions The left position or scroll options
* @param {number=} top The top position
* @return {void}
*/
scroll: function(leftOrOptions, top) {
var left = leftOrOptions;
var left;

if (typeof leftOrOptions === 'object') {
left = leftOrOptions.left;
top = leftOrOptions.top;
} else {
left = leftOrOptions;
}

left = left || 0;
top = top || 0;
if (this.scrollTarget === this._doc) {
window.scrollTo(left, top);
} else if (this._isValidScrollTarget()) {
Expand Down

0 comments on commit f710846

Please sign in to comment.