Add auto-scroll option to sky city-list example
TBR=esprehn Review URL: https://codereview.chromium.org/758753003
This commit is contained in:
parent
7da267c48b
commit
a0df465d10
@ -599,6 +599,11 @@ SkyElement({
|
||||
return;
|
||||
|
||||
this.updateView(this.loader.getItems(), true);
|
||||
},
|
||||
|
||||
scrollBy: function(amount) {
|
||||
this.scrollerElement.scrollTop += amount;
|
||||
this.handleScroll({ target: this.scrollerElement });
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -29,5 +29,21 @@ window.startLoad = new Date().getTime();
|
||||
</script>
|
||||
<body>
|
||||
<city-list></city-list>
|
||||
<script>
|
||||
var cityList = document.querySelector('city-list');
|
||||
var scrollBy = location.search.match(/auto=([0-9]+)/)[1];
|
||||
|
||||
function autoScroll() {
|
||||
cityList.scrollBy(scrollBy);
|
||||
requestAnimationFrame(autoScroll);
|
||||
}
|
||||
|
||||
if (scrollBy) {
|
||||
console.log('Autoscroll by ' + scrollBy);
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(autoScroll);
|
||||
}, 200)
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user