What's Under the Pointer?

This ad is not shown to multipass and full ticket holders
React Summit
React Summit 2026
June 11 - 15, 2026
Amsterdam & Online
The biggest React conference worldwide
Learn More
In partnership with Focus Reactive
Upcoming event
React Summit 2026
React Summit 2026
June 11 - 15, 2026. Amsterdam & Online
Learn more
Bookmark
Rate this content

Hit testing is easy, right? Learn how tldraw's canvas editor decides which shape is beneath the user's cursor. This talk is a deep dive into five hundred of the most confusing lines of code in tldraw, the infinite canvas SDK.

This talk has been presented at React Advanced 2025, check out the latest edition of this React Conference.

FAQ

Tealdraw is an application available at tealdraw.com, offering a free whiteboard that functions similarly to Miro and Excalidraw. It is also a startup that produces tealdraw.com and tealdraw.dev, an SDK for building similar applications.

Tealdraw uses a geometric system in JavaScript for hit testing, rather than relying on DOM-based methods, to efficiently manage thousands of shapes on the canvas and ensure accurate pointer interactions.

Challenges include overlapping shapes, proximity of shapes affecting selection, and the need for efficient hit testing with many shapes on the canvas.

Tealdraw's SDK solves complex canvas-related issues, allowing developers to build applications with interactive whiteboards by leveraging its existing infrastructure and solutions.

Tealdraw uses React components for rendering instead of a canvas element to leverage the flexibility and integration capabilities with web technologies, allowing for easy inclusion of videos, iframes, and other elements.

Tealdraw uses a combination of bounding boxes and distance calculations in a two-phase approach to efficiently determine which shape is being interacted with when overlaps occur.

Tealdraw's canvas is made entirely of React components and uses a unique hit testing approach, allowing for complex interactions and integrations with standard web elements.

While no one has reached the end of Tealdraw's infinite canvas yet, it is designed to be extensive enough for most practical uses.

Yes, Tealdraw is introducing AI fairies that act as agents on the canvas to build and create elements for users.

The DOM-based approach allows for seamless integration with web elements and flexibility in rendering, making it ideal for applications that require more than just graphics editing.

Steve Ruiz
Steve Ruiz
30 min
28 Nov, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Let's discuss Tealdraw, a versatile application with a whiteboard feature similar to Miro and Excalitraw. Tealdraw offers an SDK, tealdraw.dev, enabling innovative creations like a liquid simulation. Challenges in Tealdraw included optimizing hit testing, managing selection logic, and addressing shape interactions. The debugging geometry view allows for efficient handling of canvas data and hit detection. Tealdraw's approach to hit testing involves bounding boxes, shape hierarchy navigation, and handling user interactions with polygons. The talk explores technology choices, resolving logic levels, and utilizing CSS masks in Tealdraw, emphasizing the importance of user interaction and efficient hit testing processes.
Available in Español: ¿Qué hay bajo el puntero?

1. Exploring Tealdraw and Hit Testing

Short description:

Let's discuss Tealdraw, a versatile application with a whiteboard feature similar to Miro and Excalitraw. Tealdraw offers an SDK, tealdraw.dev, enabling innovative creations like a liquid simulation. The SDK tackles complex canvas problems, making it ideal for building interactive components such as hit testing for game development.

Let's talk about Tealdraw and let's talk about, of all things, hit testing and clicking, stuff like that. Just curious, how many people know about Tealdraw or have ever heard of Tealdraw? Hey, all right, that's not so bad. Cool. Well, Tealdraw is a couple of different things. It is this. It's an application, tealdraw.com. Free whiteboard. You can move things around. Works kind of like Miro, works kind of like Excalitraw, if you've ever used that.

Tealdraw is also a startup that makes tealdraw.com. And in addition to tealdraw.com, Tealdraw, the startup, also makes tealdraw.dev, which is the SDK that you can use to make things like this. I have a long list of favorites, but I always like this one a lot where you have a, I didn't make this, by the way, but this is a great liquid simulation. Fantastic. Runs in the browser, super fast. But the author also used Tealdraw as a kind of like editing environment using the whiteboard. Not necessarily for whiteboard things, but using some of the geometry inside of Tealdraw to interact with the liquid simulation. So pretty far out what you can do with Tealdraw.

And the reason why this works, and the reason why I guess it works as an SDK, is because we solve a lot of, like, super gnarly problems involved in the canvas for you. And you can build on top of that. If you've ever tried to build one of these things, it's just like a map or a text editor or something. Quite internally complex, but also those complex bits are just the way it should work. So good place for an SDK. Not that far. Today, I'm going to be talking about what's under the pointer. Originally, this was what's under the cursor. But then the cursor happened, and we thought people would be confused. So it's what's under the pointer. It's all about hit testing. General idea of if you've done game development or things like that, you might have spent a lot of time on hit testing, the whole point of, like, what am I... Where's my pointer? What am I hovering? What am I about to click on? Things like that.

2. Addressing Shape Interactions in Tealdraw

Short description:

When developing Tealdraw, challenges arose in determining user interactions with shapes and hit testing. Using DOM events and hidden SVG paths, Tealdraw managed to differentiate between various shapes and their interaction behaviors. Leveraging React components on the canvas allowed for intricate hit testing mechanisms, enhancing user experience and functionality.

So let's get into it. When Tealdraw started, it was me wanting to play around with arrows and shapes and text and things like that. And making sure that things would bind perfectly and do all this type of sizzle reel type stuff. But in order to do that, I had to solve some of these problems. So one of them is when you have a ton of different types of shapes, some of them are closed and open and filled and not filled. They're all overlapping and stuff. How do we determine what the user is hovering? Typically in the browser we don't have to think about that, because buttons just work when you click on them. They all have event listeners that kind of hide that type of hit testing, et cetera, from you.

In the old Tealdraw, the original Tealdraw, I used DOM events for this. So here's how this would work. I'll kind of show you also over here. Let me come back to that. So you had hollow shapes, you had filled shapes, you had these kind of open shapes, which are neither. And we want to select a hollow shape if we're kind of near the edge. We don't want to have to go exactly on the edge, because that might be very, very thin. But we want to just be near it. And for a filled shape, we want to be near the edge or in the middle of it. This works for open shapes as well.

And so the way that I did that in the original Tealdraw was by using kind of a hidden SVG path. So everything in Tealdraw is both old Tealdraw and new Tealdraw is DOM, right? It's a bunch of React components on the canvas. The canvas itself doesn't use a canvas element, it just has React component, React component, React component, React component. And believe it or not, that just works. You can put a lot of stuff on the canvas, even if it's React. You have to be very careful, but you can do that. So in that world, when I was using DOM elements, you'd have the normal shape. And then behind it, I was kind of doing a hidden path just to absorb that hit test from the browser, right? So the black shape has pointer events none. But this kind of hidden path behind it is the one that has the pointer events. And that's how you get this kind of like, you know, close hover hit, right? Okay. Now I'd have to adjust the size of that based on the zoom. Right? Because I needed it to be in page space or screen space rather than page.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Thinking Like an Architect
Node Congress 2025Node Congress 2025
31 min
Thinking Like an Architect
Top Content
In modern software development, architecture is more than just selecting the right tech stack; it involves decision-making, trade-offs, and considering the context of the business and organization. Understanding the problem space and focusing on users' needs are essential. Architectural flexibility is key, adapting the level of granularity and choosing between different approaches. Holistic thinking, long-term vision, and domain understanding are crucial for making better decisions. Effective communication, inclusion, and documentation are core skills for architects. Democratizing communication, prioritizing value, and embracing adaptive architectures are key to success.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!
The Dark Side of Micro-Frontends
React Advanced 2025React Advanced 2025
29 min
The Dark Side of Micro-Frontends
In the Talk, various key points were discussed regarding micro-front-end architecture. These included challenges with micro-intents, common mistakes in system design, the differences between micro-intents and components, granularity in software architecture, optimizing micro-front-end architecture, efficient routing and deployment strategies, edge computing strategies, global state and data sharing optimization, managing data context, governance and fitness functions, architectural testing, adaptive growth, value of micro-frontends, repository selection, repo structures, and web component usage.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.
Model Context Protocol (MCP) Deep Dive: 2-Hour Interactive Workshop
AI Coding SummitAI Coding Summit
86 min
Model Context Protocol (MCP) Deep Dive: 2-Hour Interactive Workshop
Workshop
Stepan Suvorov
Stepan Suvorov
Join a focused 2-hour session covering MCP's purpose, architecture, hands-on server implementation, and future directions. Designed for developers and system architects aiming to integrate contextual data with ML models effectively. Agenda:- Introduction & Why MCP? Key challenges MCP solves and core benefits.- Architecture Deep Dive: components, interactions, scalability principles. - Building Your Own MCP Server: guided walkthrough with code snippets and best practices; live demo or code review.- Future of MCP Developments: potential enhancements, emerging trends, real-world scenarios.
Key Takeaways:- Clear understanding of MCP's rationale.- Insight into design patterns and scaling considerations.- Practical steps to implement a prototype server.- Awareness of upcoming trends and how to apply MCP in projects.