-
-
Save tzvety/6aa2c3db6b470b46a7a7a0c864afa3a0 to your computer and use it in GitHub Desktop.
Resize events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
shouldBeCoral = undefined; | |
window = window; | |
constructor() { | |
} | |
attached() { | |
window.addEventListener('resize', () => this.handleResize()); | |
} | |
detached() { | |
window.removeEventListener('resize', this.handleResize); | |
} | |
handleResize() { | |
return window.innerWidth; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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