W3C home > Mailing lists > Public > public-css-archive@w3.org > July 2019

Re: [csswg-drafts] [resize-observer] device-pixel-border-box size (#3554)

From: Chris Harrelson via GitHub <sysbot+gh@w3.org>
Date: Wed, 24 Jul 2019 17:26:08 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-514724746-1563989166-sysbot+gh@w3.org>
> One note is that I _think_ (although being sure requires executing the entire [`ResizeObserver` spec](https://drafts.csswg.org/resize-observer-1/) in my head) calling `ResizeObserver.observe()` on the canvas element in question on every `requestAnimationFrame` should lead to a reliable `ResizeObserver` notification every cycle, whether the canvas has resized or not. That might be a path forward for @jdashg's use case.

Just to repeat what I said in the call also: that would indeed work and be fine, as long as you could observe the device-pixel border box of the canvas. Implementation for the developer would be:

```
function observerCallback(entry, observer) {
  let devicePixelBorderBoxRect = entry[0].devicePixelBorderBox;
  render(devicePixelBorderBoxRect); // WebGL rendering
  observer.unobserve(myCanvas);
  observer.observe(myCanvas, {box: 'device-pixel-border-box'});
}

var observer = new ResizeObserver(observerCallback);
observer.observe(myCanvas, {box: 'device-pixel-border-box'});
```

@jdashg would this meet your needs?

-- 
GitHub Notification of comment by chrishtr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3554#issuecomment-514724746 using your GitHub account
Received on Wednesday, 24 July 2019 17:26:09 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:50 UTC