[]请问laya有没有类似翻页容器(pageView)的组件?

已邀请:

cuixueying

赞同来自: wuxiaodong

有的,list下有个page属性,可以实现翻页功能!

NightFarmer

赞同来自:

同问 貌似没有找到解决方法

ZX

赞同来自:

import ConfigInfo from "../data/ConfigInfo";
import { ui } from "../ui/layaMaxUI";

export default class RuleDialog extends ui.scene.RuleDialogUI {
private m_index: number = -1;
private m_downValue: number = -1;
constructor() {
super();
this.list_rule.hScrollBarSkin = "";
this.list_rule.renderHandler = new Laya.Handler(this, this.updateItem);
this.list_rule.scrollBar.changeHandler = new Laya.Handler(this, this.onChange)
this.list_rule.mouseHandler = new Laya.Handler(this, this.onMouse)
}

onOpened(param: any) {
super.onOpened(param);
let imgArray = ;
for (let i = 1; i < 7; i++) {
imgArray.push(`ui/bg_help_0${i}.png`)
}
this.list_rule.array = imgArray;
}

public updateItem(cell: Laya.Box, index: number): void {
let img_rule = cell.getChildByName("img_rule") as Laya.Image;
img_rule.skin = cell.dataSource
let text_info = cell.getChildByName("text_des") as Laya.Text;
let i18n = Laya.loader.getRes("config/i18n.json");
text_info.text = i18n[`tips_text$text_i18n$${1101 + index}`][ConfigInfo.lang]
}

public setCurPage(index: number) {
if (this.m_index != index) {
for (let i = 1; i < 7; i++) {
let skin = "ui/round_okey_05.png"
if (index + 1 == i) {
skin = "ui/round_okey_06.png"
}
this[`img_point${i}`].skin = skin;
}
this.m_index = index;
}
}

public onChange(value: number): void {
let page = this.list_rule.scrollBar.max / this.list_rule.totalPage;
let index = Math.floor(value / page)
if (index > 5) index = 5;
this.setCurPage(index)
}


public onMouse(e: Laya.Event, index: number): void {
if (e.type == Laya.Event.MOUSE_DOWN) {
this.m_downValue = this.list_rule.scrollBar.value;
} else if (e.type == Laya.Event.MOUSE_UP || e.type == Laya.Event.MOUSE_OUT) {
if (this.m_downValue > -1) {
if (this.list_rule.scrollBar.value < this.m_downValue) {
this.list_rule.scrollBar.stopScroll();
this.list_rule.tweenTo(index - 1,100);
} else if (this.list_rule.scrollBar.value > this.m_downValue) {
this.list_rule.scrollBar.stopScroll();
this.list_rule.tweenTo(index + 1,100);
}
}
this.m_downValue = -1;
}
}
}

要回复问题请先

商务合作
商务合作