observablehq / stdlib

The Observable standard library.
https://observablehq.com/@observablehq/standard-library
ISC License
966 stars 83 forks source link

`width`: body.clientWidth vs computed width of positioned parent element #165

Closed jashkenas closed 3 years ago

jashkenas commented 4 years ago

Currently, our definition of width uses the clientWidth of the <body> element.

But when you embed a cell from a notebook, you often want to place it into an existing layout — one that is not iframed. This makes our width variable a trap: If you use it, you'll have to remove it, or know how to redefine it using the Runtime’s API, when you decide to embed.

Should we either:

mbostock commented 3 years ago

I believe this issue is now addressed through various examples that demonstrate how to override the behavior of width: https://github.com/observablehq/examples