Skip to content

Handle partial visibility state #838

@mediavrog

Description

@mediavrog

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions