How to scroll items circularly?

Hi,

Unfortunately, there is no out of box solution for this and it’s quite hard to implement.

We were thinking about supporting it in some for but well… it’s a complicated and I’d like to be sure there is a real need for this feature.

However, your example is a special case because a child covers the whole parent. So there are some simplification options. I think the simplest would be to use gestures like this:

static void item_gesture_event(lv_event_t * e)
{
    lv_obj_t * item = lv_event_get_target(e);
    lv_obj_t * parent = lv_obj_get_parent(item);
    lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());

    /*Move the last item to first place or vice versa*/ 
    lv_obj_t * item_next = NULL;
    if(dir == LV_DIR_RIGHT) {
        lv_obj_move_to_index(lv_obj_get_child(parent, -1), 0);
        item_next = lv_obj_get_child(parent, lv_obj_get_index(item) - 1);
    }
    else if(dir == LV_DIR_LEFT) {
        lv_obj_move_to_index(lv_obj_get_child(parent, 0), -1);
        item_next = lv_obj_get_child(parent, lv_obj_get_index(item) + 1);
    }

    if(item_next) {
        lv_obj_scroll_to_view(item, LV_ANIM_OFF);
        lv_obj_scroll_to_view(item_next, LV_ANIM_ON);
    }
}

...

  lv_obj_t *parent = lv_obj_create(lv_scr_act());
  lv_obj_set_size(parent, 240, 240);
  lv_obj_center(parent);
  lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_ROW);

  uint32_t i;
  for(i = 0; i < 10; i++) {
      lv_obj_t *item = lv_obj_create(parent);
      lv_obj_set_size(item, lv_pct(100), lv_pct(100));
      lv_obj_clear_flag(item, LV_OBJ_FLAG_SCROLL_CHAIN | LV_OBJ_FLAG_GESTURE_BUBBLE);
      lv_obj_add_event_cb(item, item_gesture_event, LV_EVENT_GESTURE, NULL);
      
      lv_obj_t * label = lv_label_create(item);
      lv_label_set_text_fmt(label, "%d", i+1);
      lv_obj_center(label);
  }

  /*Move the last item to the first place and focus on the second item*/
  lv_obj_move_to_index(lv_obj_get_child(parent, -1), 0);
  lv_obj_scroll_to_view(lv_obj_get_child(parent, 1), LV_ANIM_OFF);

s