@websy/websy-designs 1.4.24 → 1.4.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -188,14 +188,7 @@ class ButtonGroup {
188
188
  handleClick (event) {
189
189
  if (event.target.classList.contains('websy-button-group-item')) {
190
190
  const index = +event.target.getAttribute('data-index')
191
- if (this.options.activeItem !== index) {
192
- if (this.options.onDeactivate && this.options.activeItem !== -1) {
193
- this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem)
194
- }
195
- this.options.activeItem = index
196
- if (this.options.onActivate) {
197
- this.options.onActivate(this.options.items[index], index, event)
198
- }
191
+ if (this.options.activeItem !== index) {
199
192
  const el = document.getElementById(this.elementId)
200
193
  let buttons = Array.from(el.querySelectorAll('.websy-button-group-item'))
201
194
  buttons.forEach(el => {
@@ -204,7 +197,14 @@ class ButtonGroup {
204
197
  el.classList.remove('active')
205
198
  })
206
199
  event.target.classList.remove('inactive')
207
- event.target.classList.add('active')
200
+ event.target.classList.add('active')
201
+ if (this.options.onDeactivate && this.options.activeItem !== -1) {
202
+ this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem, true)
203
+ }
204
+ this.options.activeItem = index
205
+ if (this.options.onActivate) {
206
+ this.options.onActivate(this.options.items[index], index, event)
207
+ }
208
208
  }
209
209
  else if (this.options.activeItem === index && this.options.allowNone === true) {
210
210
  if (this.options.onDeactivate) {
@@ -243,16 +243,6 @@ var ButtonGroup = /*#__PURE__*/function () {
243
243
  var index = +event.target.getAttribute('data-index');
244
244
 
245
245
  if (this.options.activeItem !== index) {
246
- if (this.options.onDeactivate && this.options.activeItem !== -1) {
247
- this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem);
248
- }
249
-
250
- this.options.activeItem = index;
251
-
252
- if (this.options.onActivate) {
253
- this.options.onActivate(this.options.items[index], index, event);
254
- }
255
-
256
246
  var el = document.getElementById(this.elementId);
257
247
  var buttons = Array.from(el.querySelectorAll('.websy-button-group-item'));
258
248
  buttons.forEach(function (el) {
@@ -262,6 +252,16 @@ var ButtonGroup = /*#__PURE__*/function () {
262
252
  });
263
253
  event.target.classList.remove('inactive');
264
254
  event.target.classList.add('active');
255
+
256
+ if (this.options.onDeactivate && this.options.activeItem !== -1) {
257
+ this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem, true);
258
+ }
259
+
260
+ this.options.activeItem = index;
261
+
262
+ if (this.options.onActivate) {
263
+ this.options.onActivate(this.options.items[index], index, event);
264
+ }
265
265
  } else if (this.options.activeItem === index && this.options.allowNone === true) {
266
266
  if (this.options.onDeactivate) {
267
267
  this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem);