@@ -142,12 +142,8 @@ export default class Panels {
142142 action : {
143143 click : evt => {
144144 const index = indexOfNode ( evt . target , evt . target . parentElement )
145+ this . nav . setTranslateX ( index , false )
145146 this . nav . groupChange ( index )
146- // this.currentPanel = this.panels[index]
147- // const labels = this.labels.querySelectorAll('h5')
148- // this.nav.refresh(index)
149- // dom.removeClasses(labels, 'active-tab')
150- // evt.target.classList.add('active-tab')
151147 } ,
152148 } ,
153149 content : panel . config . label ,
@@ -228,21 +224,22 @@ export default class Panels {
228224 const action = { }
229225 const groupParent = this . currentPanel . parentElement
230226 const labelWrap = this . labels . firstChild
227+ const panelTabs = labelWrap . children
231228 const siblingGroups = this . currentPanel . parentElement . childNodes
232229 this . activePanelIndex = indexOfNode ( this . currentPanel , groupParent )
233230 let offset = { nav : 0 , panel : 0 }
234231 let lastOffset = { ...offset }
235232
236233 action . groupChange = newIndex => {
237234 this . activePanelIndex = newIndex
238- const labels = labelWrap . children
239- dom . removeClasses ( siblingGroups , 'active-panel' )
240- dom . removeClasses ( labels , 'active-tab' )
241235 this . currentPanel = siblingGroups [ newIndex ]
236+
237+ dom . removeClasses ( siblingGroups , 'active-panel' )
238+ dom . removeClasses ( panelTabs , 'active-tab' )
239+
242240 this . currentPanel . classList . add ( 'active-panel' )
243- labels [ newIndex ] . classList . add ( 'active-tab' )
244-
245- action . setTranslateX ( newIndex )
241+ panelTabs [ newIndex ] . classList . add ( 'active-tab' )
242+
246243 return this . currentPanel
247244 }
248245
@@ -257,8 +254,6 @@ export default class Panels {
257254 const panelQueue = [ getTransition ( lastOffset . panel ) , getTransition ( offset . panel ) ]
258255 const navQueue = [ getTransition ( lastOffset . nav ) , getTransition ( this . isTabbed ? 0 : offset . nav ) ]
259256
260- debugger
261-
262257 if ( reset ) {
263258 const [ panelStart ] = panelQueue
264259 const [ navStart ] = navQueue
@@ -293,11 +288,9 @@ export default class Panels {
293288
294289 action . refresh = ( newIndex = this . activePanelIndex ) => {
295290 if ( this . activePanelIndex !== newIndex ) {
296- this . activePanelIndex = newIndex
297291 action . groupChange ( newIndex )
298292 }
299- // debugger
300- action . setTranslateX ( this . activePanelIndex )
293+ action . setTranslateX ( this . activePanelIndex , false )
301294 this . resizePanels ( )
302295 }
303296
@@ -308,13 +301,13 @@ export default class Panels {
308301 action . nextGroup = ( ) => {
309302 const newIndex = this . activePanelIndex + 1
310303 if ( newIndex !== siblingGroups . length ) {
311- const curPanel = action . groupChange ( newIndex )
304+ const nextPanel = siblingGroups [ newIndex ]
312305 offset = {
313306 nav : - labelWrap . offsetWidth * newIndex ,
314- panel : - curPanel . offsetLeft ,
307+ panel : - nextPanel . offsetLeft ,
315308 }
316309 translateX ( { offset } )
317- this . activePanelIndex ++
310+ action . groupChange ( newIndex )
318311 } else {
319312 offset = {
320313 nav : lastOffset . nav - 8 ,
@@ -329,13 +322,13 @@ export default class Panels {
329322 action . prevGroup = ( ) => {
330323 if ( this . activePanelIndex !== 0 ) {
331324 const newIndex = this . activePanelIndex - 1
332- const curPanel = action . groupChange ( newIndex )
325+ const prevPanel = siblingGroups [ newIndex ]
333326 offset = {
334327 nav : - labelWrap . offsetWidth * newIndex ,
335- panel : - curPanel . offsetLeft ,
328+ panel : - prevPanel . offsetLeft ,
336329 }
337330 translateX ( { offset } )
338- this . activePanelIndex --
331+ action . groupChange ( newIndex )
339332 } else {
340333 offset = {
341334 nav : 8 ,
0 commit comments