Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Created August 24, 2016 22:39
Show Gist options
  • Select an option

  • Save jdanyow/db47a4f26f48e17250f2812ad159ea28 to your computer and use it in GitHub Desktop.

Select an option

Save jdanyow/db47a4f26f48e17250f2812ad159ea28 to your computer and use it in GitHub Desktop.
<template>
<style>
.scroll-container {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
border: 1px solid blue;
overflow-y: auto;
}
.scroll-top-indicator {
position: absolute;
right: 70px;
color: red;
}
</style>
<!-- subscribe to scroll events and update the view-model's scrollTop property -->
<div class="scroll-container" ref="myDiv"
scroll.trigger="scrollTop = myDiv.scrollTop & throttle">
<!-- create some content to overflow the container -->
<p repeat.for="i of 200">hello ${i}</p>
</div>
<!-- display the scrollTop -->
<span class="scroll-top-indicator">scrollTop = ${scrollTop}px</span>
</template>
export class App {
scrollTop = 0;
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment