10:53

In this tutorial Ray Deck walks through the process of adding the Fabric.js canvas library to a WeWeb application. He starts by explaining what Fabric.js is—a JavaScript library that provides higher‑level drawing and interaction capabilities for an HTML5 canvas. Because WeWeb does not expose a native canvas component, he creates a plain HTML element, inserts a <canvas> tag, and gives it a fixed width and height. To load Fabric.js, he demonstrates two approaches: adding a script tag to the page header (which requires a publish) and, more flexibly, using a WeWeb page‑load workflow that runs custom JavaScript to inject the script via the state‑change embed converter. After the library is loaded, he adds a button component, attaches a click workflow, and writes custom JavaScript that selects the canvas by its ID, creates a Fabric.Rectangle, sets its fill colour, and adds it to the canvas. He shows the result in preview, then modifies the colour to illustrate editing the script. Finally, he uncovers a timing issue: the Fabric.js script loads asynchronously, so code that runs immediately after the load may fail with “Fabric is not defined”. He resolves this by inserting a setTimeout delay (e.g., 1000 ms) before executing the drawing code, effectively waiting for the library to be available. The tutorial ends with a working example where clicking the button draws a coloured rectangle on the canvas, demonstrating how to combine external JavaScript libraries with WeWeb’s low‑code workflow system.

Chapters

More from Ray

youtube.com

Be the Looker

7mo ago
youtube.com

Operators Optimize, Innovators Integrate

7mo ago
youtube.com

Move Over Vibe Coding

7mo ago
youtube.com

Two Customer Challenges

7mo ago
youtube.com

Trust is a Competitive Moat

7mo ago
youtube.com

Be Verbose With Your Errors

7mo ago
youtube.com

Build for AI, Not Just With It

7mo ago
youtube.com

A Technology Business

7mo ago
youtube.com

Interdimensional Studying

7mo ago
youtube.com

Interdimensional Learning

7mo ago
youtube.com

Gain True Mastery

7mo ago
See all content