[LayaAir 1.0]List翻页效果怎么实现


BY0E6]VHE((9`32QB}_~M6Q.png

这种效果,鼠标滑动会滑到下一项而不是在中间停住
已邀请:

熊猫大侠

赞同来自:

你是要实现 你图片里面的效果还是 什么

159*****136

赞同来自:

LIST的功能本就很基础的功能,你要的效果自己用mouseOver加Tween自己写一个就是,代码也不复杂

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

要回复问题请先

商务合作
商务合作