Skip to content

Commit

Permalink
Merge pull request #29 from koirodev/next
Browse files Browse the repository at this point in the history
fix(core): Fixed event calls in the settings.
  • Loading branch information
koirodev authored Dec 19, 2024
2 parents 7d569c1 + 867bd04 commit c9479a1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.2.2 - Released on 2024-12-19

### Bug Fixes
- Fixed event calls in the settings.


## 3.2.1 - Released on 2024-12-19

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kordion",
"version": "3.2.1",
"version": "3.2.2",
"description": "Contemporary style and functionality - an accordion that does more.",
"type": "module",
"main": "./dist/kordion.mjs",
Expand Down
30 changes: 11 additions & 19 deletions src/core/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ class Kordion {
this.settings.effectLineByLine = { ...lineByLineOptions, ...this.settings.effectLineByLine };

// Инициализация аккордеона | Initializing the accordion
if (this.settings.events.before.init) {
if (this.settings.events && this.settings.events.before && this.settings.events.before.init) {
this.settings.events.before.init(this);
}

this.init();

if (this.settings.events.after.init) {
if (this.settings.events && this.settings.events.after && this.settings.events.after.init) {
this.settings.events.after.init(this);
}
}
Expand All @@ -76,7 +74,7 @@ class Kordion {
element.classList.add(`kordion_${this.settings.theme}`);

// Обработка события клика на аккордеон
if (this.settings.events.click) {
if (this.settings.events && this.settings.events.click) {
instance.kordion.addEventListener("click", (event) => {
this.settings.events.click(this, event);
});
Expand All @@ -93,7 +91,7 @@ class Kordion {
}
});

if (this.settings.events.on.init) {
if (this.settings.events && this.settings.events.on && this.settings.events.on.init) {
this.settings.events.on.init(this);
}
}
Expand Down Expand Up @@ -210,16 +208,14 @@ class Kordion {
// Переключение аккордеона | Toggling the accordion
toggle(instance) {
if (instance.kordion.classList.contains(this.settings.activeClass)) {
if (this.settings.events.before.hide) {
if (this.settings.events && this.settings.events.before && this.settings.events.before.hide) {
this.settings.events.before.hide(this, instance);
}

this.hide(instance)
this.hide(instance);
} else {
if (this.settings.events.before.show) {
if (this.settings.events && this.settings.events.before && this.settings.events.before.show) {
this.settings.events.before.show(this, instance);
}

this.show(instance);
}

Expand Down Expand Up @@ -252,20 +248,18 @@ class Kordion {
// Замена иконки аккордеона | Replacing the accordion icon
clearTimeout(instance.replaceIconTO);
instance.replaceIconTO = setTimeout(() => {
if (this.settings.events.on.show) {
if (this.settings.events && this.settings.events.on && this.settings.events.on.show) {
this.settings.events.on.show(this, instance);
}

this.replaceIcon(instance, false);
}, this.settings.speed / 2);

// Конец анимации аккордеона | End of accordion animation
clearTimeout(instance.afterToggleTO);
instance.afterToggleTO = setTimeout(() => {
if (this.settings.events.after.show) {
if (this.settings.events && this.settings.events.after && this.settings.events.after.show) {
this.settings.events.after.show(this, instance);
}

instance.content.classList.remove(this.settings.disabledClass);

// Фикс бага с высотой контента | Fixing the content height bug
Expand Down Expand Up @@ -311,19 +305,17 @@ class Kordion {
clearTimeout(instance.replaceIconTO);
instance.replaceIconTO = setTimeout(() => {
this.replaceIcon(instance, true);

if (this.settings.events.on.hide) {
if (this.settings.events && this.settings.events.on && this.settings.events.on.hide) {
this.settings.events.on.hide(this, instance);
}
}, this.settings.speed / 2);

// Окончание закрытия аккордеона | End of closing the accordion
clearTimeout(instance.afterToggleTO);
instance.afterToggleTO = setTimeout(() => {
if (this.settings.events.after.hide) {
if (this.settings.events && this.settings.events.after && this.settings.events.after.hide) {
this.settings.events.after.hide(this, instance);
}

instance.content.classList.remove(this.settings.disabledClass);
}, this.settings.speed);

Expand Down

0 comments on commit c9479a1

Please sign in to comment.