Skip to content

Commit

Permalink
layout.Card: afterSetActiveIndex() => limiting the current logic to s…
Browse files Browse the repository at this point in the history
…lideDirection == null
  • Loading branch information
tobiu committed Apr 21, 2024
1 parent f314a31 commit 72602d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
6 changes: 3 additions & 3 deletions examples/layout/card/MainContainer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MainContainer extends ConfigurationViewport {

layout.activeIndex++;
data.component.disabled = layout.activeIndex === cardContainer.items.length - 1;
this.getItem('prev-button').disabled = false;
this.getItem('prev-button').disabled = false
}

/**
Expand All @@ -126,7 +126,7 @@ class MainContainer extends ConfigurationViewport {
*/
onRadioLayoutChange(config, value, opts) {
if (opts.value === true) { // we only want to listen to check events, not uncheck
this.getItem('card-container').layout[config] = value;
this.getItem('card-container').layout[config] = value
}
}

Expand All @@ -139,7 +139,7 @@ class MainContainer extends ConfigurationViewport {

layout.activeIndex--;
data.component.disabled = layout.activeIndex === 0;
this.getItem('next-button').disabled = false;
this.getItem('next-button').disabled = false
}
}

Expand Down
44 changes: 25 additions & 19 deletions src/layout/Card.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,40 @@ class Card extends Base {
module = item.module;

if (isActiveIndex && Neo.typeOf(module) === 'Function') {
item = await me.loadModule(item, i);
item = await me.loadModule(item, i)
}

if (item instanceof Neo.component.Base) {
wrapperCls = item.wrapperCls;

NeoArray.remove(wrapperCls, isActiveIndex ? sCfg.inactiveItemCls : sCfg.activeItemCls);
NeoArray.add( wrapperCls, isActiveIndex ? sCfg.activeItemCls : sCfg.inactiveItemCls);

if (removeInactiveCards || needsUpdate) {
item.wrapperCls = wrapperCls;

if (isActiveIndex) {
delete item.vdom.removeDom;
item.activate?.();
} else if (removeInactiveCards) {
item.mounted = false;
item.vdom.removeDom = true;
if (!me.slideDirection) {
if (item instanceof Neo.component.Base) {
wrapperCls = item.wrapperCls;

NeoArray.remove(wrapperCls, isActiveIndex ? sCfg.inactiveItemCls : sCfg.activeItemCls);
NeoArray.add( wrapperCls, isActiveIndex ? sCfg.activeItemCls : sCfg.inactiveItemCls);

if (removeInactiveCards || needsUpdate) {
item.wrapperCls = wrapperCls;

if (isActiveIndex) {
delete item.vdom.removeDom;
item.activate?.()
} else if (removeInactiveCards) {
item.mounted = false;
item.vdom.removeDom = true
}
} else {
item.wrapperCls = wrapperCls
}
} else {
item.wrapperCls = wrapperCls;
}
}
}

if (removeInactiveCards || needsUpdate) {
if (!me.slideDirection && (removeInactiveCards || needsUpdate)) {
container.update();
}

if (me.slideDirection) {
console.log('animate update')
}
}
}

Expand Down

0 comments on commit 72602d5

Please sign in to comment.