Files
fc/dev/project/assets/Scripts/nx/cmp/flex/nx.fx.sv.expand.item.js
T
2026-05-23 22:10:14 +08:00

80 lines
1.7 KiB
JavaScript

/******************************************************************
* Copyright(C) 2019 - 2020 Nx Studio
*
* NX UI插件 -- 动态扩充列表表项
*
* 2018.05.18
******************************************************************/
cc.Class( {
extends: cc.Component,
properties: {
flexHeight: { default: false },
},
// 数据重置
rebind: function( _idx, _data, _key ) {
this.index = _idx;
this.mdata = _data;
this.key = _key || "";
this.openFlexHeight( this.flexHeight );
},
// 开关点击支持
openTouch: function( _open, _cb ) {
this.touchOpened = _open;
this.touchCB = _cb;
if( _open ) {
this.node.on( "touchend", this.onTouch, this );
} else {
this.node.off( "touchend", this.onTouch, this );
}
},
// 激活( 不可见->可见 )
inShow: function(){},
// 反激活( 可见->不可见 )
outShow: function(){},
// 聚焦获得
onFocus: function(){},
// 聚焦失去
outFocus: function(){},
// 开启不定高模式
openFlexHeight: function( _open ) {
this.node.off( "size-changed", this.onSizeChanged, this );
if( _open ) {
this.node.on( "size-changed", this.onSizeChanged, this );
}
},
// 自身尺寸改变了
onSizeChanged: function() {
let parent = this.node.parent;
if( parent ) {
parent.height = this.node.height;
}
},
// 点击触发
onTouch: function() {
if( this.touchOpened &&
nx.dt.fnGood( this.touchCB ) ) {
this.touchCB( this );
}
},
} );