How to scrollTop a div whose content is managed by AngularDart?

前端 未结 3 2005
忘掉有多难
忘掉有多难 2021-01-21 13:56

I have a div holding some chat history. I would like for the div content to scroll when it becomes full. I have this working using jQuery in another p

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 14:19

    If you're using an AngularDart component you can inject the shadowdom then select an element inside it to focus on. Didnt find a way of getting the container of the shadowdom.

    new Future.delayed(new Duration(milliseconds: 300), () {
      var rowElement = _shadowRoot.querySelector('.step-container');
      if (rowElement != null ) {
        rowElement.scrollIntoView(ScrollAlignment.TOP);
      }
    });
    

    ShadowDom.host might work, though its currently marked as experimental.

提交回复
热议问题