Visibility actions

An element can perform actions without user input: when it appears on the screen and when it disappears from it. Such actions are set in the visibility_actions and disappear_actions properties. In addition to their own parameters, they support the main parameters of regular actions: url, typed, log_id, is_enabled, payload, scope_id, referer, and download_callbacks.

Actions when appearing

visibility elements are triggered when an element is shown on the screen.

{
  "visibility_actions": [
    {
      "log_id":"content_01_visibility",
      "visibility_percentage": 100,
      "visibility_duration": 1000,
      "url": "div-action://none"
    }
  ]
}

Parameter

Description

visibility_percentage

Percentage of the element's visible area.

visibility_duration

The minimum time of its visibility.

log_id

Optional logging ID for the visibility action.

By default, visibility_percentage is 50 and visibility_duration is 800 ms. The log_limit parameter limits how many times the action is triggered and logged: the default value is 1, so the action runs once. The value 0 removes the limit.

Note

Older versions of DivKit clients ignore visibility actions without log_id. If such clients also receive the card, specify log_id.

Actions when disappearing

Disappear elements are triggered when the element is no longer visible.

{
  "disappear_actions": [
    {
      "log_id": "content_01_disappear",
      "visibility_percentage": 0,
      "disappear_duration": 800,
      "url": "div-action://none"
    }
  ]
}

Parameter

Description

visibility_percentage

Percentage of the visible part of the element that triggers the action. The default value is 0.

disappear_duration

Time in milliseconds during which the element must be outside the visible area to trigger the action. The default value is 800.

log_id

ID for logging the action.

log_limit

Limit on how many times the action is triggered and logged. The default value is 1, and 0 removes the limit.

Learn more

You can discuss topics of interest in the DivKit user community in Telegram: https://t.me/divkit_community_en.

DivKit Repository