Scroll to with offset

This example is an experimental workaround to solve issues around scrolling into a view where there is an offset needed.

This example is for scrolling up from the element (works with popover positioned from Top). If you want to scroll from the bottom, it should be quite straightforward to change it.

It adds to the scroll the height of the popover with the content, to make sure it scrolls enough.

Implementing the callback

In your application source code insert:

  window.im_callbacks = {
      imScrollVert: function(player_id, topic_id, step_id, custom_data) {
        if (custom_data.offset == undefined) custom_data.offset = 0;
        element = document.querySelector('.fczbkk-popover-wrapper');
        popover = DomBox.getBox(element);
        var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
        window.scrollTo(0, top - popover.height - 20 - custom_data.offset);

Using the function in the Authoring tool

In the Authoring tool, you can re-use the callback wherever necessary.

In the Authoring tool:

  1. Within the Callbacks panel, add a callback im_callbacks.imScrollVert in On show section.

  2. Additionally, you can add a parameter: offset which will add to the scrolling position.

  3. Click + under Custom data tab.

  4. Provide name offset and value.

Was this article helpful?