-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6235 grid.Scrollbar: base class & scss
- Loading branch information
Showing
3 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.neo-grid-scrollbar { | ||
background-color: red; | ||
bottom : 0; | ||
overflow-y : scroll; | ||
position : absolute; | ||
right : 0; | ||
top : 31px; // header-toolbar height | ||
transition : opacity .4s; | ||
width : 16px; | ||
z-index : 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import Component from '../component/Base.mjs'; | ||
|
||
/** | ||
* @class Neo.grid.Scrollbar | ||
* @extends Neo.component.Base | ||
*/ | ||
class GridScrollbar extends Component { | ||
static config = { | ||
/** | ||
* @member {String} className='Neo.grid.Scrollbar' | ||
* @protected | ||
*/ | ||
className: 'Neo.grid.Scrollbar', | ||
/** | ||
* @member {String} ntype='grid-scrollbar' | ||
* @protected | ||
*/ | ||
ntype: 'grid-scrollbar', | ||
/** | ||
* @member {String[]} baseCls=['neo-grid-scrollbar'] | ||
* @protected | ||
*/ | ||
baseCls: ['neo-grid-scrollbar'], | ||
/** | ||
* Number in px | ||
* @member {Number} rowHeight_=0 | ||
*/ | ||
rowHeight_: 0, | ||
/** | ||
* @member {Neo.data.Store|null} store_=null | ||
*/ | ||
store_: null, | ||
/** | ||
* @member {Object} _vdom | ||
*/ | ||
_vdom: | ||
{cn: [ | ||
{cls: ['neo-grid-scrollbar-content']} | ||
]} | ||
} | ||
|
||
/** | ||
* Triggered after the rowHeight config got changed | ||
* @param {Number} value | ||
* @param {Number} oldValue | ||
* @protected | ||
*/ | ||
afterSetRowHeight(value, oldValue) { | ||
value > 0 && this.updateScrollHeight() | ||
} | ||
|
||
/** | ||
* Triggered after the store config got changed | ||
* @param {Neo.data.Store|null} value | ||
* @param {Neo.data.Store|null} oldValue | ||
* @protected | ||
*/ | ||
afterSetStore(value, oldValue) { | ||
if (value) { | ||
let me = this; | ||
|
||
value.on({ | ||
load : me.updateScrollHeight, | ||
scope: me | ||
}); | ||
|
||
value.getCount() > 0 && me.updateScrollHeight() | ||
} | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
updateScrollHeight() { | ||
let me = this, | ||
countRecords = me.store.getCount(), | ||
{rowHeight} = me; | ||
|
||
if (countRecords > 0 && rowHeight > 0) { | ||
me.vdom.cn[0].height = `${countRecords * rowHeight}px`; | ||
me.update() | ||
} | ||
} | ||
} | ||
|
||
export default Neo.setupClass(GridScrollbar); |