Skip to content

Commit

Permalink
#6235 main.addon.ScrollSync: base class
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiu committed Feb 7, 2025
1 parent e25a546 commit 49c0bc0
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/grid/Scrollbar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,39 @@ class GridScrollbar extends Component {
]}
}

/**
* @param {Boolean} mounted
* @protected
*/
async addScrollSync(mounted) {
let me = this,
ScrollSync = Neo.main?.addon?.ScrollSync,
{windowId} = me,
params = {id: me.id, windowId};

if (!ScrollSync) {
await Neo.Main.importAddon({name: 'ScrollSync', windowId});
ScrollSync = Neo.main.addon.ScrollSync
}

if (mounted) {
ScrollSync.register(params)
} else {
ScrollSync.unregister(params)
}
}

/**
* Triggered after the mounted config got changed
* @param {Boolean} value
* @param {Boolean} oldValue
* @protected
*/
afterSetMounted(value, oldValue) {
super.afterSetMounted(value, oldValue);
oldValue !== undefined && this.addScrollSync(value)
}

/**
* Triggered after the rowHeight config got changed
* @param {Number} value
Expand Down
43 changes: 43 additions & 0 deletions src/main/addon/ScrollSync.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Base from './Base.mjs';

/**
* Syncs the scroll state of 2 DOM nodes
* @class Neo.main.addon.ScrollSync
* @extends Neo.main.addon.Base
*/
class ScrollSync extends Base {
static config = {
/**
* @member {String} className='Neo.main.addon.ScrollSync'
* @protected
*/
className: 'Neo.main.addon.ScrollSync',
/**
* Remote method access for other workers
* @member {Object} remote
* @protected
*/
remote: {
app: [
'register',
'unregister'
]
}
}

/**
* @param {Object} data
*/
register(data) {
console.log('register', data)
}

/**
* @param {Object} data
*/
unregister(data) {
console.log('unregister', data)
}
}

export default Neo.setupClass(ScrollSync);

0 comments on commit 49c0bc0

Please sign in to comment.