mirror of
https://ark.sudovanilla.org/Korbs/electron-tabs.git
synced 2024-12-22 19:43:53 +00:00
Add basic methods for tab position
This commit is contained in:
parent
357197848d
commit
8d3f6183a0
21
index.js
21
index.js
|
@ -271,6 +271,27 @@ class Tab extends EventEmitter {
|
||||||
TabGroupPrivate.activateRecentTab.bind(tabGroup)();
|
TabGroupPrivate.activateRecentTab.bind(tabGroup)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPosition () {
|
||||||
|
let i = 0;
|
||||||
|
let tab = this.tab;
|
||||||
|
while ((tab = tab.previousSibling) != null) i++;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPosition (newPosition) {
|
||||||
|
let tabContainer = this.tabGroup.tabContainer;
|
||||||
|
let tabs = tabContainer.children;
|
||||||
|
let oldPosition = this.getPosition();
|
||||||
|
|
||||||
|
if (newPosition > oldPosition) {
|
||||||
|
newPosition++;
|
||||||
|
}
|
||||||
|
|
||||||
|
tabContainer.insertBefore(tabs[oldPosition], tabs[newPosition]);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabPrivate = {
|
const TabPrivate = {
|
||||||
|
|
Loading…
Reference in a new issue