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;
|
return;
|
||||||
|
|
||||||
this.updateView(this.loader.getItems(), true);
|
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>
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<city-list></city-list>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user