From 72602d54d497795bfa9e920d79ce699e0d86e6dc Mon Sep 17 00:00:00 2001 From: tobiu Date: Sun, 21 Apr 2024 21:20:24 +0200 Subject: [PATCH] layout.Card: afterSetActiveIndex() => limiting the current logic to slideDirection == null --- examples/layout/card/MainContainer.mjs | 6 ++-- src/layout/Card.mjs | 44 +++++++++++++++----------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/examples/layout/card/MainContainer.mjs b/examples/layout/card/MainContainer.mjs index a7cef3539..67bf18904 100644 --- a/examples/layout/card/MainContainer.mjs +++ b/examples/layout/card/MainContainer.mjs @@ -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 } /** @@ -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 } } @@ -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 } } diff --git a/src/layout/Card.mjs b/src/layout/Card.mjs index 6a774f9cb..a0b0d7a45 100644 --- a/src/layout/Card.mjs +++ b/src/layout/Card.mjs @@ -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') + } } }