久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <small id='iGCGG'></small><noframes id='iGCGG'>

    2. <tfoot id='iGCGG'></tfoot>

      <i id='iGCGG'><tr id='iGCGG'><dt id='iGCGG'><q id='iGCGG'><span id='iGCGG'><b id='iGCGG'><form id='iGCGG'><ins id='iGCGG'></ins><ul id='iGCGG'></ul><sub id='iGCGG'></sub></form><legend id='iGCGG'></legend><bdo id='iGCGG'><pre id='iGCGG'><center id='iGCGG'></center></pre></bdo></b><th id='iGCGG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iGCGG'><tfoot id='iGCGG'></tfoot><dl id='iGCGG'><fieldset id='iGCGG'></fieldset></dl></div>
      <legend id='iGCGG'><style id='iGCGG'><dir id='iGCGG'><q id='iGCGG'></q></dir></style></legend>
        <bdo id='iGCGG'></bdo><ul id='iGCGG'></ul>
    3. ionic 2 + angular 2:自動滾動到列表/頁面/聊天的底部

      ionic 2 + angular 2 : auto scroll to bottom of list / page / chat(ionic 2 + angular 2:自動滾動到列表/頁面/聊天的底部)

          1. <i id='edMrC'><tr id='edMrC'><dt id='edMrC'><q id='edMrC'><span id='edMrC'><b id='edMrC'><form id='edMrC'><ins id='edMrC'></ins><ul id='edMrC'></ul><sub id='edMrC'></sub></form><legend id='edMrC'></legend><bdo id='edMrC'><pre id='edMrC'><center id='edMrC'></center></pre></bdo></b><th id='edMrC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='edMrC'><tfoot id='edMrC'></tfoot><dl id='edMrC'><fieldset id='edMrC'></fieldset></dl></div>
            • <bdo id='edMrC'></bdo><ul id='edMrC'></ul>

              <tfoot id='edMrC'></tfoot>

              <legend id='edMrC'><style id='edMrC'><dir id='edMrC'><q id='edMrC'></q></dir></style></legend>

              <small id='edMrC'></small><noframes id='edMrC'>

                <tbody id='edMrC'></tbody>
              1. 本文介紹了ionic 2 + angular 2:自動滾動到列表/頁面/聊天的底部的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在嘗試編寫包含聊天"和內容"兩個部分的頁面.我希望那個聊天"分段頁面自動滾動到底部而沒有效果.聊天是一個 <ion-list> 和幾個 <ion-item>.

                I'm trying to code a page with two segments "chat" and "content". I want that one "chat" segment the page auto-scroll to the bottom with no effect. The chat is a <ion-list> with several <ion-item>.

                <ion-list>
                <ion-item> item 1 </ion-item>
                <ion-item> item 2 </ion-item>
                ....
                <ion-item> item 20 </ion-item>
                <ion-item> item 21 </ion-item> <!-- user should see directly this item on bottom of the page -->
                </ion-list>
                

                我使用的是 Javascript,而不是 typescript,而且我不想使用 jQuery.謝謝 :)另外,當我轉到內容"部分并返回聊天"時,我想再次自動滾動聊天.

                I'm using Javascript, not typescript, and I don't wan't to use jQuery. Thanks :) Plus, when I go to "content" segment and go back to "chat" I want to auto-scroll again the chat.

                推薦答案

                首先,@rinukkusu 的答案是正確的,但它不適用于我的情況,因為 <ion-content> (<ion-list>) 的父級有一些錯誤(離子開發人員正在解決這個問題),所以我不得不將該元素與 scroll:hidden 并創建里面的第二個內容以應用自動滾動.最后,當頁面加載時,我在 construtor 上調用了正確的 (s)css 函數,然后每次用戶點擊聊天"段時.

                First off all, @rinukkusu answer is right but it doesn't work on my case because <ion-content> (parent of <ion-list>) has some bugs with it (ionic developers are working on that), so I had to put that element with scroll:hidden and create a second content inside to apply the auto-scroll. Finally with the right (s)css I called the function on construtor when the page loads and then each time the users clicks on "chat" segment.

                chat.html

                <!-- I create the segment and call the `autoScroll()` when users clicks on "chat" -->
                <ion-toolbar primary class="toolbar-segment">
                    <ion-segment light [(ngModel)]="segment">
                        <ion-segment-button value="chat" (click)="autoScroll()">
                            Chat
                        </ion-segment-button>
                        <ion-segment-button value="profile">
                            Profile
                        </ion-segment-button>
                    </ion-segment>
                </ion-toolbar>
                
                <!--I wrote the css inline just as example. 
                  DON'T do it on your project D: -->
                
                <!-- overflow:hidden prevent the ion-content to scroll -->
                <ion-content [ngSwitch]="segment" style="overflow: hidden;">
                
                    <!-- height: 100% to force scroll if the content overflows the container.
                         #chat-autoscroll is used by javascript.-->
                    <div class="content-scroll" id="chat-autoscroll" *ngSwitchWhen="'chat'" style="height: 100%; overflow: scroll">
                        (... make sure the content is bigger 
                        than the container to see the auto scroll effect ...)
                    </div>
                
                    <!-- here it's just a normal scroll  -->
                    <div *ngSwitchWhen="'profile'" class="content-scroll" style="height: 100%; overflow: auto">
                      (... content of profile segment ...)
                    </div>
                
                </ion-content>
                

                chat.js

                constructor () {
                
                    // when the user opens the page, it shows the "chat" segment as initial value
                    this.segment = 'chat'; 
                
                    // when page loads, it calls autoScroll();
                    if (this.segment == 'chat') {
                        console.log('chat');
                        this.autoScroll();
                    };
                }
                
                /*Here comes the tricky. 
                 If you don't use setTimeout, the console will say that
                 #chat-autoscroll doesn't exist in the first call (inside constructor). 
                 This happens because the script runs before the DOM is ready. 
                 I did a workaround with a timeOut of 10ms.
                 It's enough time to DOM loads and then autoScroll() works fine.
                */
                autoScroll() {
                    setTimeout(function () {
                        var itemList = document.getElementById("chat-autoscroll");
                        itemList.scrollTop = itemList.scrollHeight;
                    }, 10);
                }
                

                結論:該函數被調用兩次.當頁面被加載(構造函數)并且每次用戶回到聊天"段時.(click)="autoScroll()"

                Conclusion: The function is called twice. When the page is loaded (constructor) and each time the user comes back to "chat" segment. (click)="autoScroll()"

                我希望這對某人有所幫助.如果您知道更好的方法,請告訴我!幾周前我開始使用 Angular2 和 Ionic2,所以這里可能缺少很多概念/基礎.

                I hope this helps someone. If you know better way, let me know! I started playing with Angular2 and Ionic2 a couple of weeks ago so there is a lot of concepts/bases that I might be missing here.

                謝謝:)

                這篇關于ionic 2 + angular 2:自動滾動到列表/頁面/聊天的底部的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                    • <small id='37qZq'></small><noframes id='37qZq'>

                      • <bdo id='37qZq'></bdo><ul id='37qZq'></ul>

                      • <i id='37qZq'><tr id='37qZq'><dt id='37qZq'><q id='37qZq'><span id='37qZq'><b id='37qZq'><form id='37qZq'><ins id='37qZq'></ins><ul id='37qZq'></ul><sub id='37qZq'></sub></form><legend id='37qZq'></legend><bdo id='37qZq'><pre id='37qZq'><center id='37qZq'></center></pre></bdo></b><th id='37qZq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='37qZq'><tfoot id='37qZq'></tfoot><dl id='37qZq'><fieldset id='37qZq'></fieldset></dl></div>

                            <tbody id='37qZq'></tbody>
                          <tfoot id='37qZq'></tfoot>
                          <legend id='37qZq'><style id='37qZq'><dir id='37qZq'><q id='37qZq'></q></dir></style></legend>

                        1. 主站蜘蛛池模板: 日韩精品久久久 | 91精品久久久久久久久久入口 | 欧美激情精品久久久久 | 偷拍自拍第一页 | 亚洲国产精品人人爽夜夜爽 | 亚洲色图插插插 | 国内精品久久影院 | www.五月天婷婷.com | 午夜影院在线视频 | 91久色| 99精品免费视频 | 亚洲免费在线 | 九色视频网站 | 韩日一区二区 | 欧美成视频在线观看 | 欧美在线色 | 亚洲天堂男人的天堂 | 国产一区二区三区高清 | 亚洲精品乱码久久久久久按摩观 | aaa国产大片 | 午夜日韩 | 国产精品久久久久久久久久尿 | 国产美女h视频 | 黄视频免费| 日本精品久久久久久久 | 久久久国产精品视频 | 一区二区三区在线 | 男女视频免费 | 日韩在线视频一区二区三区 | 久久精彩视频 | 亚洲精品久久久久久国产精华液 | 欧美综合在线观看 | 国产成视频在线观看 | 久久综合国产精品 | 天啪 | 久久久国产精品 | 最新av中文字幕 | 欧美日韩精品一区二区三区四区 | 丁香久久 | 日本理论片好看理论片 | 91视频在线 |