I have a computed getter function I created that essentially checked if a scroll bar exists and if it does, a component is moved to adjust for the scroll bar. Here is the code:
get scrollTrackOffset() {
const rowCount = this.yKeys.length || 0;
const totalRowHeight = rowCount * this.rowHeight;
return totalRowHeight > this.height ? 15 : 0;
}
The 'yKeys' for reference is a separate computed getter that always returns an array which will determine if a scroll bar exists or not. My question is that is there a way for me to make
const rowCount = this.yKeys.length || 0;
const totalRowHeight = rowCount * this.rowHeight;
return totalRowHeight > this.height ? 15 : 0;
into a reuse-able function where I can input the parameters such as this.height and this.yKeys?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/RoE0aZM
Comments
Post a Comment