久久久久久久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:自動滾動到列表/頁面/聊天的底部的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我正在嘗試編寫包含聊天"和內(nèi)容"兩個部分的頁面.我希望那個聊天"分段頁面自動滾動到底部而沒有效果.聊天是一個 <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.謝謝 :)另外,當(dāng)我轉(zhuǎn)到內(nèi)容"部分并返回聊天"時,我想再次自動滾動聊天.

                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>) 的父級有一些錯誤(離子開發(fā)人員正在解決這個問題),所以我不得不將該元素與 scroll:hidden 并創(chuàng)建里面的第二個內(nèi)容以應(yīng)用自動滾動.最后,當(dāng)頁面加載時,我在 construtor 上調(diào)用了正確的 (s)css 函數(shù),然后每次用戶點擊聊天"段時.

                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);
                }
                

                結(jié)論:該函數(shù)被調(diào)用兩次.當(dāng)頁面被加載(構(gòu)造函數(shù))并且每次用戶回到聊天"段時.(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,所以這里可能缺少很多概念/基礎(chǔ).

                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.

                謝謝:)

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

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

                相關(guān)文檔推薦

                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 - 使用異步數(shù)據(jù)更新 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 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態(tài)元素 - 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. 主站蜘蛛池模板: 成人免费网站在线 | 国产第一区二区 | 国产精品免费观看 | www.99re| 国产成人一区二区三区 | 一区二区三区精品视频 | 一区二区亚洲 | 久久久久久久久久影视 | 成人超碰 | 成人aaa视频| 精品国产一区二区在线 | 国产第一页在线观看 | 国产一区二区三区色淫影院 | 女同久久另类99精品国产 | 亚洲国产精品人人爽夜夜爽 | av网站在线播放 | 国产一级在线 | 青久草视频 | 91一区二区 | 精品香蕉一区二区三区 | 91精品久久久久久久久久入口 | 久久久精品 | 国产精品久久久久久久久久久久 | 亚洲精品4| 亚洲 精品 综合 精品 自拍 | 亚洲欧美日韩在线不卡 | 羞羞的视频免费看 | 四虎成人在线播放 | 成人免费区一区二区三区 | 久久久久无码国产精品一区 | 久久99精品久久久久久 | 亚洲综合区 | av黄色在线 | 欧美成人免费 | 黄网站免费观看 | 成人在线免费观看 | 999久久久 | 色噜噜狠狠色综合中国 | 中文字幕免费 | 99热成人在线 | 91超碰在线 |