It’s probably worth structuring this a bit differently:

```js
if (inside || visible) {
  listener.polygonStart();
  if (inside) { … }
  if (visible) { … }
  listener.polygonEnd();
}
```