zoukankan      html  css  js  c++  java
  • scroller,,list里面滚动到最后,,再添加10条数据

    class ScrollerPosition extends eui.UILayer{
        private scroller:eui.Scroller;
        public listArray:Array<number> = [];
        constructor(){
            super();
            //创建一个列表
            var list = new eui.List();
            this.listArray = [1,2,3,4,5,6,7];
            list.dataProvider = new eui.ArrayCollection(this.listArray);
            //创建一个scroller
            var scroller = new eui.Scroller();
            scroller.height = 160;
            scroller.viewport = list;
            this.addChild(scroller);
            this.scroller = scroller;
    
            //https://developer.egret.com/cn/article/index/id/611
            //需要在scroller添加到舞台上面之后再访问verticalScrollBar
            // scroller.verticalScrollBar.autoVisibility = false;
            // scroller.verticalScrollBar.visible = false;
    
    
            //创建一个按钮,点击后改变Scroller被动的位置
            var btn = new eui.Button();
            btn.x = 200;
            this.addChild(btn);
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.moveScroller,this);
        }
        protected createChildren(){
            //初始化后改变被动的位置
            this.scroller.viewport.validateNow();
            this.scroller.viewport.scrollV = 40;
        }
    
        private moveScroller():void{
            //点击按钮后改变被动的位置
            var sc = this.scroller;
            sc.viewport.scrollV += 10;
            if((sc.viewport.scrollV + screen.height) > sc.viewport.contentHeight){
                console.log("滚动到底部");
                this.listArray.push(12,23,33,43,35,63,37);
            }
            //停止正在被动的动画
            sc.stopAnimation();
    
        }
    
    }
  • 相关阅读:
    SQL Server OPENQUERY使用
    VS2013程序打包报 ISEXP : error -****: An error occurred streaming
    IIS重新注册
    c#之反射(Reflection)
    c#之Lambda表达式
    c#之委托事件(DelegateEvent)
    c#之委托详解(Delegate)
    git将文件托管到github上遇到的问题
    c#之泛型详解(Generic)
    linux下操作memcache的操作命令
  • 原文地址:https://www.cnblogs.com/Lauren-J/p/10308009.html
Copyright © 2011-2022 走看看