pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    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="83r23yv" 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="eilnqj3" 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="mfmsra7" 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. 主站蜘蛛池模板: 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 上海公众号开发-公众号代运营公司-做公众号的公司企业服务商-咏熠软件 | 农业仪器网 - 中国自动化农业仪器信息交流平台 | 深圳装修_店面装修设计_餐厅设计_装修全包价格-尚泰装饰设计 | IP检测-检测您的IP质量 | 旗杆生产厂家_不锈钢锥形旗杆价格_铝合金电动旗杆-上海锥升金属科技有限公司 | 祝融环境-地源热泵多恒系统高新技术企业,舒适生活环境缔造者! | 洁净棚-洁净工作棚-无菌室-净化工程公司_北京卫护科技有限公司 | 昆山新莱洁净应用材料股份有限公司-卫生级蝶阀,无菌取样阀,不锈钢隔膜阀,换向阀,离心泵 | 中央空调维修、中央空调保养、螺杆压缩机维修-苏州东菱空调 | 葡萄酒灌装机-食用油灌装机-液体肥灌装设备厂家_青州惠联灌装机械 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 杭州代理记账费用-公司注销需要多久-公司变更监事_杭州福道财务管理咨询有限公司 | 精密交叉滚子轴承厂家,转盘轴承,YRT转台轴承-洛阳千协轴承 | 中国产业发展研究网 - 提供行业研究报告 可行性研究报告 投资咨询 市场调研服务 | 耳模扫描仪-定制耳机设计软件-DLP打印机-asiga打印机-fitshape「飞特西普」 | 厦门ISO认证|厦门ISO9001认证|厦门ISO14001认证|厦门ISO45001认证-艾索咨询专注ISO认证行业 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | 污水处理设备-海普欧环保集团有限公司 | AGV无人叉车_激光叉车AGV_仓储AGV小车_AGV无人搬运车-南昌IKV机器人有限公司[官网] | 餐饮加盟网_特色餐饮连锁加盟店-餐饮加盟官网 | 工业机械三维动画制作 环保设备原理三维演示动画 自动化装配产线三维动画制作公司-南京燃动数字 聚合氯化铝_喷雾聚氯化铝_聚合氯化铝铁厂家_郑州亿升化工有限公司 | R507制冷剂,R22/R152a制冷剂厂家-浙江瀚凯制冷科技有限公司 | 南京办公用品网-办公文具用品批发-打印机耗材采购| 食药成分检测_调料配方还原_洗涤剂化学成分分析_饲料_百检信息科技有限公司 | 自动气象站_气象站监测设备_全自动气象站设备_雨量监测站-山东风途物联网 | 协议书_协议合同格式模板范本大全 | 北京晚会活动策划|北京节目录制后期剪辑|北京演播厅出租租赁-北京龙视星光文化传媒有限公司 | 尊享蟹太太美味,大闸蟹礼卡|礼券|礼盒在线预订-蟹太太官网 | 外贮压-柜式-悬挂式-七氟丙烷-灭火器-灭火系统-药剂-价格-厂家-IG541-混合气体-贮压-非贮压-超细干粉-自动-灭火装置-气体灭火设备-探火管灭火厂家-东莞汇建消防科技有限公司 | 玻璃瓶厂家_酱菜瓶厂家_饮料瓶厂家_酒瓶厂家_玻璃杯厂家_徐州东明玻璃制品有限公司 | 温州食堂承包 - 温州市尚膳餐饮管理有限公司 | 北京康百特科技有限公司-分子蒸馏-短程分子蒸馏设备-实验室分子蒸馏设备 | 培训无忧网-教育培训咨询招生第三方平台 | 智能终端_RTU_dcm_北斗星空自动化科技 | PO膜_灌浆膜及地膜供应厂家 - 青州市鲁谊塑料厂 | 定制防伪标签_防伪标签印刷_防伪标签厂家-510品保防伪网 | 洛阳永磁工业大吊扇研发生产-工厂通风降温解决方案提供商-中实洛阳环境科技有限公司 | 临海涌泉蜜桔官网|涌泉蜜桔微商批发代理|涌泉蜜桔供应链|涌泉蜜桔一件代发 | 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | 工业制氮机_psa制氮机厂家-宏骁智能装备科技江苏有限公司 |