From 8d3f6183a03e09633f8238e373e036ce2a53ccd6 Mon Sep 17 00:00:00 2001 From: W Etheredge Date: Thu, 26 Oct 2017 18:36:19 -0500 Subject: [PATCH] Add basic methods for tab position --- index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/index.js b/index.js index 0092357..89f1113 100644 --- a/index.js +++ b/index.js @@ -271,6 +271,27 @@ class Tab extends EventEmitter { 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 = {