JSFiddle - React, Tailwind, and code Playground
by Marco Abate
HTML
<canvas id="carousel" width="150" height="150"></canvas>
SCSS
$dark: #333333;
body {
background-color: $dark;
}
TypeScript
class Carousel {
private selector: string;
private canvas: HTMLCanvasElement | null = null
private context = null
constructor(selector: string) {
this.selector = selector;
this.onInit();
}
private onInit() {
this.canvas = document.querySelector(this.selector);
this.context = this.canvas.getContext('2d');
console.log(this.context)
}
}
new Carousel('#carousel');