- 注册时间
- 2017-7-27
- 最后登录
- 2020-12-5
- 阅读权限
- 20
- 积分
- 52
- 精华
- 0
- 帖子
- 11

|
发表于 2019-7-12 16:22:14
|显示全部楼层
lufy 发表于 2019-7-11 15:25 
这个你可以试一下引擎的LListView组件
http://lufylegend.com/api/zh_CN/out/classes/UIListView.html ...
我在官方demo中做了些修改,来复现实际在项目中使用遇到的问题,以下是代码;
现象:在蓝色区域拖动效果正常,橘色区域“基本无效果,得使劲使劲频繁才有效”,以下附上图片- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>UI:LListView</title>
- <script type="text/javascript" src="../load_lufylegend.js"></script>
- <script type="text/javascript" src="../load_lufylegend.ui.js"></script>
- </head>
- <body style="margin:0;padding:0;">
- <div id="legend"></div>
- <script>
- //-----------------新加-----------------------------
- var screen_width = window.innerWidth;
- var screen_height = window.innerHeight;
- var screen_rate = 2;
- //-----------------新加-----------------------------
- init(1000/60,"legend",screen_width*screen_rate,screen_height*screen_rate,main);
- var backLayer, ctrlLayer, listView, index = 1;
- function MyListChildView(i){
- var self = this;
- base(self,LListChildView,[]);
- var rand = Math.random();
- self.graphics.drawRect(1, "#000000", [0, 0, 100, 30],true,rand < 0.33?"#90EE90":(rand < 0.66 ? "#F4A460":"#E6E6FA"));
- var t = new LTextField();
- t.text = "点击删除"+i;
- t.x = t.y = 5;
- self.addChild(t);
- }
- MyListChildView.prototype.onClick = function(event){
- event.currentTarget.deleteChildView(event.target);
- };
- function main(){
- //-----------------新加-----------------------------
- LGlobal.canvasObj.style.width = screen_width + "px";
- LGlobal.canvasObj.style.height = screen_height + "px";
- LGlobal.canvasStyleWidth = screen_width;
- LGlobal.canvasStyleHeight = screen_height;
- //-----------------新加-----------------------------
- LMouseEventContainer.set(LMouseEvent.MOUSE_DOWN,true);
- LMouseEventContainer.set(LMouseEvent.MOUSE_UP,true);
- LMouseEventContainer.set(LMouseEvent.MOUSE_MOVE,true);
- LGlobal.setDebug(true);
- ctrlLayer = new LSprite();
- addChild(ctrlLayer);
- backLayer = new LSprite();
- backLayer.x = (LGlobal.width-600)*0.5;
- backLayer.y = (LGlobal.height-600)*0.5;
- addChild(backLayer);
- var button01 = new LButtonSample1("点击按钮添加单元");
- button01.x = 30;
- button01.y = 10;
- ctrlLayer.addChild(button01);
- button01.addEventListener(LMouseEvent.MOUSE_UP,addListChildView);
- //-----------------修改-----------------------------
- listViewInit(600,600);
- //-----------------修改-----------------------------
- }
- function listViewInit(width,height){
- listView = new LListView();
- backLayer.addChild(listView);
- listView.maxPerLine = 3;
- listView.cellWidth = 100;
- listView.cellHeight = 30;
- //-----------------修改-----------------------------
- listView.resize(width,height);
- //-----------------修改-----------------------------
- listView.arrangement = LListView.Direction.Horizontal;
- listView.movement = LListView.Direction.Vertical;
- listView.graphics.drawRect(1, "#00ff00", [0, 0, listView.clipping.width,listView.clipping.height]);
- }
- function addListChildView(){
- var child = new MyListChildView(index++);
- listView.insertChildView(child);
- }
- </script>
- </body>
- </html>
复制代码 |
|