@@ -142,11 +142,8 @@ export default class Panels {
142142 action : {
143143 click : evt => {
144144 const index = indexOfNode ( evt . target , evt . target . parentElement )
145- this . currentPanel = this . panels [ index ]
146- const labels = evt . target . parentElement . childNodes
147- this . nav . refresh ( index )
148- dom . removeClasses ( labels , 'active-tab' )
149- evt . target . classList . add ( 'active-tab' )
145+ this . nav . setTranslateX ( index , false )
146+ this . nav . groupChange ( index )
150147 } ,
151148 } ,
152149 content : panel . config . label ,
@@ -227,19 +224,21 @@ export default class Panels {
227224 const action = { }
228225 const groupParent = this . currentPanel . parentElement
229226 const labelWrap = this . labels . firstChild
227+ const panelTabs = labelWrap . children
230228 const siblingGroups = this . currentPanel . parentElement . childNodes
231229 this . activePanelIndex = indexOfNode ( this . currentPanel , groupParent )
232230 let offset = { nav : 0 , panel : 0 }
233231 let lastOffset = { ...offset }
234232
235233 action . groupChange = newIndex => {
236- const labels = labelWrap . children
237- dom . removeClasses ( siblingGroups , 'active-panel' )
238- dom . removeClasses ( labels , 'active-tab' )
234+ this . activePanelIndex = newIndex
239235 this . currentPanel = siblingGroups [ newIndex ]
240- this . currentPanel . classList . add ( 'active-panel' )
241236
242- labels [ newIndex ] . classList . add ( 'active-tab' )
237+ dom . removeClasses ( siblingGroups , 'active-panel' )
238+ dom . removeClasses ( panelTabs , 'active-tab' )
239+
240+ this . currentPanel . classList . add ( 'active-panel' )
241+ panelTabs [ newIndex ] . classList . add ( 'active-tab' )
243242
244243 return this . currentPanel
245244 }
@@ -278,6 +277,7 @@ export default class Panels {
278277 lastOffset = offset
279278 }
280279 }
280+
281281 panelTransition . addEventListener ( 'finish' , handleFinish )
282282 }
283283
@@ -288,10 +288,9 @@ export default class Panels {
288288
289289 action . refresh = ( newIndex = this . activePanelIndex ) => {
290290 if ( this . activePanelIndex !== newIndex ) {
291- this . activePanelIndex = newIndex
292291 action . groupChange ( newIndex )
293292 }
294- action . setTranslateX ( this . activePanelIndex )
293+ action . setTranslateX ( this . activePanelIndex , false )
295294 this . resizePanels ( )
296295 }
297296
@@ -302,13 +301,13 @@ export default class Panels {
302301 action . nextGroup = ( ) => {
303302 const newIndex = this . activePanelIndex + 1
304303 if ( newIndex !== siblingGroups . length ) {
305- const curPanel = action . groupChange ( newIndex )
304+ const nextPanel = siblingGroups [ newIndex ]
306305 offset = {
307306 nav : - labelWrap . offsetWidth * newIndex ,
308- panel : - curPanel . offsetLeft ,
307+ panel : - nextPanel . offsetLeft ,
309308 }
310309 translateX ( { offset } )
311- this . activePanelIndex ++
310+ action . groupChange ( newIndex )
312311 } else {
313312 offset = {
314313 nav : lastOffset . nav - 8 ,
@@ -323,13 +322,13 @@ export default class Panels {
323322 action . prevGroup = ( ) => {
324323 if ( this . activePanelIndex !== 0 ) {
325324 const newIndex = this . activePanelIndex - 1
326- const curPanel = action . groupChange ( newIndex )
325+ const prevPanel = siblingGroups [ newIndex ]
327326 offset = {
328327 nav : - labelWrap . offsetWidth * newIndex ,
329- panel : - curPanel . offsetLeft ,
328+ panel : - prevPanel . offsetLeft ,
330329 }
331330 translateX ( { offset } )
332- this . activePanelIndex --
331+ action . groupChange ( newIndex )
333332 } else {
334333 offset = {
335334 nav : 8 ,
0 commit comments