This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree 1 file changed +20
-0
lines changed
list/elements/polymer-virtual-list
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 53
53
this . metrics = {
54
54
scrollOffset : h ? 'scrollLeft' : 'scrollTop' ,
55
55
offsetExtent : h ? 'offsetWidth' : 'offsetHeight' ,
56
+ offsetPosition : h ? 'offsetLeft' : 'offsetTop' ,
56
57
extent : h ? 'width' : 'height' ,
57
58
position : h ? 'left' : 'top'
58
59
} ;
260
261
}
261
262
}
262
263
}
264
+ } ,
265
+ setScrollOffsetImmediate : function ( pos ) {
266
+ this . scrollOffset = pos ;
267
+ this . scroll ( ) ;
268
+ } ,
269
+ scrollToRow : function ( row ) {
270
+ // find page and row in page
271
+ var pageNum = Math . floor ( row / this . pageSize ) ;
272
+ // guesstimate offset and scroll to it
273
+ var top = this . pageTops [ pageNum ] || this . calcPageTop ( pageNum ) ;
274
+ this . setScrollOffsetImmediate ( top ) ;
275
+ // re-scroll with updated info
276
+ var top = this . pageTops [ pageNum ] ;
277
+ this . setScrollOffsetImmediate ( top ) ;
278
+ // scroll to offset on this page
279
+ var page = this . findPage ( pageNum ) ;
280
+ var rowInPage = row - pageNum * this . pageSize ;
281
+ var rowOffset = page . children [ rowInPage ] [ this . metrics . offsetPosition ] ;
282
+ this . scrollOffset += rowOffset ;
263
283
}
264
284
} ) ;
265
285
</ script >
You can’t perform that action at this time.
0 commit comments