Skip to content

Commit f710846

Browse files
authored
Merge pull request #41 from PolymerElements/rictic-patch-1
Improve type safety of scroll method
2 parents c36cc42 + efaf4f5 commit f710846

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

iron-scroll-target-behavior.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ declare namespace Polymer {
107107
* @param leftOrOptions The left position or scroll options
108108
* @param top The top position
109109
*/
110-
scroll(leftOrOptions: number|ScrollToOptions, top?: number): void;
110+
scroll(leftOrOptions: number|{left: number, top: number}, top?: number): void;
111111

112112
/**
113113
* Returns true if the scroll target is a valid HTMLElement.

iron-scroll-target-behavior.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,22 @@
190190
* Scrolls the content to a particular place.
191191
*
192192
* @method scroll
193-
* @param {number|!ScrollToOptions} leftOrOptions The left position or scroll options
193+
* @param {number|!{left: number, top: number}} leftOrOptions The left position or scroll options
194194
* @param {number=} top The top position
195195
* @return {void}
196196
*/
197197
scroll: function(leftOrOptions, top) {
198-
var left = leftOrOptions;
198+
var left;
199199

200200
if (typeof leftOrOptions === 'object') {
201201
left = leftOrOptions.left;
202202
top = leftOrOptions.top;
203+
} else {
204+
left = leftOrOptions;
203205
}
204206

207+
left = left || 0;
208+
top = top || 0;
205209
if (this.scrollTarget === this._doc) {
206210
window.scrollTo(left, top);
207211
} else if (this._isValidScrollTarget()) {

0 commit comments

Comments
 (0)