-
-
Save AshleyGrant/bd093ad54032055da1da to your computer and use it in GitHub Desktop.
Aurelia Gist
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 style="height: 125px; min-width: 150px; width: 100%;" ref="canvasContainer"> | |
<canvas ref="canvas" width.one-way="canvasContainer.offsetWidth"></canvas> | |
</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
import {PLATFORM} from 'aurelia-pal'; | |
export class App { | |
resizeTimer = null; | |
resizeEventHandler = () => this.resized(); | |
attached() { | |
this.resized(); | |
PLATFORM.global.addEventListener("resize", this.resizeEventHandler); | |
} | |
detached() { | |
PLATFORM.global.removeEventListener("resize", this.resizeEventHandler); | |
} | |
resized() { | |
clearTimeout(this.resizeTimer); | |
this.resizeTimer = setTimeout(() => { | |
let ctx = this.canvas.getContext("2d"); | |
ctx.fillStyle = "green"; | |
ctx.font = "30px Arial"; | |
ctx.fillText(`Width: ${this.canvas.width}`,10,50); | |
}, 150); | |
} | |
} |
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"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment