question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle partial visibility state

See original GitHub issue

Requirements for our project have visibility tracking of elements at 50% visibility. Since both VisibilityState.FOCUSED_VISIBLE and VisibilityState.FULL_IMPRESSION_VISIBLE do not cover this state, we were thinking of extending the visibility tracker.

The idea would be to offer some api to define a threshold (range 0…1) for when a visibility state would be triggered. This could either be applied to the VisibilityState.FULL_IMPRESSION_VISIBLE, which would redefine what a full impression is in the app context, or preferably introduce a new state VisibilityState.PARTIAL_IMPRESSION_VISIBLE. Implementation would be very similar to VisibilityItem#handleFullImpressionVisible.

Now we could probably handle this using the visibilityChanged, but it would be more involved to not double-count the impression and it would trigger quite often (so we would not be able to disable the noisy onChanged (visibilityChangedEnabled).

I think there might be more use-cases which would warrant to have a single-event impression for a certain threshold of visibility. If you think it might be useful, I will whip up a PR within the next weeks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
eboudrantcommented, May 3, 2020

Thanks, I added few comments but overall looks good.

Could you clarify “defining a list of thresholds”? I think the only case were we wanted to use it would be with one threshold only. Do you need multiple?

1reaction
mediavrogcommented, Apr 21, 2020

Hi @eboudrant, sorry for leaving this discussion for a long time. I have created a draft of a PR over at https://github.com/smartnews/epoxy/pull/1/files, could you please give feedback on the general direction of this approach? Does this seem reasonable?

TODO

  • tests
  • threshold _INVISIBLE state?

Do you think one threshold would be ok, or should it support defining a list of thresholds?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page Visibility API - MDN Web Docs - Mozilla
A string indicating the document's current visibility state. Possible values are: visible. The page content may be at least partially visible.
Read more >
Page Visibility Level 2 - W3C
The document is at least partially visible on at least one screen, as determined by running the steps to determine the visibility state...
Read more >
visibilitychange event is not triggered when switching program ...
Here's a roundup post I wrote for this issue and a workaround in pure JavaScript to solve the encountered problems.
Read more >
Handling Visibility - Litho
Describes the APIs to handle visibility of components. ... The event object states the visible top and left coordinate, and the current visible...
Read more >
Dynamic Block - Visibility state combining with a Array function
After stretching the window to a value of the (Parameter)List, you choose the visibility "without" (without additional block). If you stretch to any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found