Skip to content

Instantly share code, notes, and snippets.

@tzvety
Forked from taosd/app.html
Last active September 18, 2020 21:31
Show Gist options
  • Save tzvety/6aa2c3db6b470b46a7a7a0c864afa3a0 to your computer and use it in GitHub Desktop.
Save tzvety/6aa2c3db6b470b46a7a7a0c864afa3a0 to your computer and use it in GitHub Desktop.
Resize events
<template>
<div class="wrapper ${(window.innerWidth > 700) ? 'resized' : ''}" >
Resize me <br/><hr style="height: 1px; border: 0; background-color: black; ">
Window width: ${window.innerWidth}
</div>
</template>
export class App {
shouldBeCoral = undefined;
window = window;
constructor() {
}
attached() {
window.addEventListener('resize', () => this.handleResize());
}
detached() {
window.removeEventListener('resize', this.handleResize);
}
handleResize() {
return window.innerWidth;
};
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.wrapper {
width: 100%;
height: 555px;
background-color: lightblue;
padding: 50px 0 0 50px;
font-size: 40px;
}
.wrapper.resized {
background-color: lightcoral;
}
</style>
</head>
<body aurelia-app="main" class="m-4">
<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>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment