it looks like you could do something like…

```js
var rightEdge = pos.left + actualWidth + viewportPadding
if (rightEdge > viewportDimensions.width) {
  delta.left = viewportDimensions.left + viewportDimensions.width - rightEdge
}
```