Add auto-scroll option to sky city-list example

TBR=esprehn

Review URL: https://codereview.chromium.org/758753003
This commit is contained in:
Rafael Weinstein 2014-11-24 16:15:19 -08:00
parent 7da267c48b
commit a0df465d10
2 changed files with 21 additions and 0 deletions

View File

@ -599,6 +599,11 @@ SkyElement({
return;
this.updateView(this.loader.getItems(), true);
},
scrollBy: function(amount) {
this.scrollerElement.scrollTop += amount;
this.handleScroll({ target: this.scrollerElement });
}
});

View File

@ -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>