@syncfusion/ej2-navigations 33.1.47 → 33.1.49

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.
@@ -140,22 +140,8 @@ let HScroll = class HScroll extends Component {
140
140
  ele.classList.remove(CLS_RTL);
141
141
  const nav = selectAll('.e-' + ele.id + '_nav.' + CLS_HSCROLLNAV, ele);
142
142
  const overlay = selectAll('.' + CLS_OVERLAY, ele);
143
- [].slice.call(overlay).forEach((oElem) => {
144
- if (this.onKeyPressBound) {
145
- oElem.removeEventListener('keydown', this.onKeyPressBound);
146
- }
147
- if (this.onKeyUpBound) {
148
- oElem.removeEventListener('keyup', this.onKeyUpBound);
149
- }
150
- if (this.repeatScrollBound) {
151
- oElem.removeEventListener('mouseup', this.repeatScrollBound);
152
- oElem.removeEventListener('touchend', this.repeatScrollBound);
153
- }
154
- if (this.contextMenuBound) {
155
- oElem.removeEventListener('contextmenu', this.contextMenuBound);
156
- }
157
- EventHandler.remove(oElem, 'click', this.clickEventHandler);
158
- detach(oElem);
143
+ [].slice.call(overlay).forEach((ele) => {
144
+ detach(ele);
159
145
  });
160
146
  for (const elem of [].slice.call(this.scrollItems.children)) {
161
147
  ele.appendChild(elem);
@@ -165,37 +151,14 @@ let HScroll = class HScroll extends Component {
165
151
  }
166
152
  detach(this.scrollEle);
167
153
  if (nav.length > 0) {
168
- [].slice.call(nav).forEach((nElem) => {
169
- if (this.onKeyPressBound) {
170
- nElem.removeEventListener('keydown', this.onKeyPressBound);
171
- }
172
- if (this.onKeyUpBound) {
173
- nElem.removeEventListener('keyup', this.onKeyUpBound);
174
- }
175
- if (this.repeatScrollBound) {
176
- nElem.removeEventListener('mouseup', this.repeatScrollBound);
177
- nElem.removeEventListener('touchend', this.repeatScrollBound);
178
- }
179
- if (this.contextMenuBound) {
180
- nElem.removeEventListener('contextmenu', this.contextMenuBound);
181
- }
182
- EventHandler.remove(nElem, 'click', this.clickEventHandler);
183
- detach(nElem);
184
- });
154
+ detach(nav[0]);
155
+ if (!isNullOrUndefined(nav[1])) {
156
+ detach(nav[1]);
157
+ }
185
158
  }
186
159
  EventHandler.remove(this.scrollEle, 'scroll', this.scrollHandler);
187
160
  this.touchModule.destroy();
188
161
  this.touchModule = null;
189
- if (this.navTouchCollection) {
190
- this.navTouchCollection.forEach((t) => { if (t && typeof t.destroy === 'function') {
191
- t.destroy();
192
- } });
193
- this.navTouchCollection = null;
194
- }
195
- this.onKeyPressBound = null;
196
- this.onKeyUpBound = null;
197
- this.repeatScrollBound = null;
198
- this.contextMenuBound = null;
199
162
  super.destroy();
200
163
  }
201
164
  /**
@@ -280,34 +243,17 @@ let HScroll = class HScroll extends Component {
280
243
  }
281
244
  eventBinding(ele) {
282
245
  [].slice.call(ele).forEach((el) => {
283
- const navTouch = new Touch(el, { tapHold: this.tabHoldHandler.bind(this), tapHoldThreshold: 500 });
284
- if (!this.navTouchCollection) {
285
- this.navTouchCollection = [];
286
- }
287
- this.navTouchCollection.push(navTouch);
288
- if (!this.onKeyPressBound) {
289
- this.onKeyPressBound = this.onKeyPress.bind(this);
290
- }
291
- if (!this.onKeyUpBound) {
292
- this.onKeyUpBound = this.onKeyUp.bind(this);
293
- }
294
- if (!this.repeatScrollBound) {
295
- this.repeatScrollBound = this.repeatScroll.bind(this);
296
- }
297
- if (!this.contextMenuBound) {
298
- this.contextMenuBound = this.contextMenuHandler.bind(this);
299
- }
300
- el.addEventListener('keydown', this.onKeyPressBound);
301
- el.addEventListener('keyup', this.onKeyUpBound);
302
- el.addEventListener('mouseup', this.repeatScrollBound);
303
- el.addEventListener('touchend', this.repeatScrollBound);
304
- el.addEventListener('contextmenu', this.contextMenuBound);
246
+ new Touch(el, { tapHold: this.tabHoldHandler.bind(this), tapHoldThreshold: 500 });
247
+ el.addEventListener('keydown', this.onKeyPress.bind(this));
248
+ el.addEventListener('keyup', this.onKeyUp.bind(this));
249
+ el.addEventListener('mouseup', this.repeatScroll.bind(this));
250
+ el.addEventListener('touchend', this.repeatScroll.bind(this));
251
+ el.addEventListener('contextmenu', (e) => {
252
+ e.preventDefault();
253
+ });
305
254
  EventHandler.add(el, 'click', this.clickEventHandler, this);
306
255
  });
307
256
  }
308
- contextMenuHandler(e) {
309
- e.preventDefault();
310
- }
311
257
  repeatScroll() {
312
258
  clearInterval(this.timeout);
313
259
  }
@@ -1197,6 +1143,7 @@ let MenuBase = class MenuBase extends Component {
1197
1143
  this.isAnimationNone = false;
1198
1144
  this.isKBDAction = false;
1199
1145
  this.skipNextArrowDown = false;
1146
+ this.isCmenuOpened = false;
1200
1147
  }
1201
1148
  /**
1202
1149
  * Initialized third party configuration settings.
@@ -1368,15 +1315,18 @@ let MenuBase = class MenuBase extends Component {
1368
1315
  new Touch(target, { tapHold: this.touchHandler.bind(this) });
1369
1316
  }
1370
1317
  else {
1371
- EventHandler.add(target, 'contextmenu', this.cmenuHandler, this);
1318
+ this.delegateContextMenuHandler = this.cmenuHandler.bind(this);
1319
+ EventHandler.add(target, 'contextmenu', this.delegateContextMenuHandler, this);
1372
1320
  }
1373
1321
  }
1374
1322
  }
1375
1323
  this.targetElement = target;
1376
1324
  if (!this.isMenu) {
1377
1325
  EventHandler.add(this.targetElement, 'scroll', this.scrollHandler, this);
1378
- for (const parent of getScrollableParent(this.targetElement)) {
1379
- EventHandler.add(parent, 'scroll', this.scrollHandler, this);
1326
+ this.scrollParents = getScrollableParent(this.targetElement).slice();
1327
+ this.delegateParentScrollHandler = this.scrollHandler.bind(this);
1328
+ for (const parent of this.scrollParents) {
1329
+ EventHandler.add(parent, 'scroll', this.delegateParentScrollHandler, this);
1380
1330
  }
1381
1331
  }
1382
1332
  }
@@ -1704,6 +1654,7 @@ let MenuBase = class MenuBase extends Component {
1704
1654
  if (this.isCMenu) {
1705
1655
  if (this.canOpen(e.target)) {
1706
1656
  this.openMenu(null, null, this.pageY, this.pageX, e);
1657
+ this.isCmenuOpened = true;
1707
1658
  }
1708
1659
  this.isCMenu = false;
1709
1660
  }
@@ -3080,14 +3031,22 @@ let MenuBase = class MenuBase extends Component {
3080
3031
  }
3081
3032
  }
3082
3033
  else {
3083
- EventHandler.remove(target, 'contextmenu', this.cmenuHandler);
3034
+ if (this.delegateContextMenuHandler) {
3035
+ EventHandler.remove(target, 'contextmenu', this.delegateContextMenuHandler);
3036
+ this.delegateContextMenuHandler = null;
3037
+ }
3084
3038
  }
3085
3039
  }
3086
3040
  }
3087
3041
  if (!this.isMenu) {
3088
3042
  EventHandler.remove(this.targetElement, 'scroll', this.scrollHandler);
3089
- for (const parent of getScrollableParent(this.targetElement)) {
3090
- EventHandler.remove(parent, 'scroll', this.scrollHandler);
3043
+ if (this.scrollParents) {
3044
+ for (const parent of this.scrollParents) {
3045
+ EventHandler.remove(parent, 'scroll', this.delegateParentScrollHandler);
3046
+ }
3047
+ this.delegateParentScrollHandler = null;
3048
+ this.scrollParents.length = 0;
3049
+ this.scrollParents = null;
3091
3050
  }
3092
3051
  }
3093
3052
  }
@@ -3558,6 +3517,17 @@ let MenuBase = class MenuBase extends Component {
3558
3517
  const wrapper = this.getWrapper();
3559
3518
  if (wrapper) {
3560
3519
  this.unWireEvents();
3520
+ this.delegateClickHandler = null;
3521
+ this.delegateMoverHandler = null;
3522
+ this.delegateMouseDownHandler = null;
3523
+ this.delegateDomKeyHandler = null;
3524
+ this.delegateScrollHandler = null;
3525
+ this.delegateTouchOutsideHandler = null;
3526
+ this.delegateParentScrollHandler = null;
3527
+ if (this.delegateContextMenuHandler) {
3528
+ EventHandler.remove(this.targetElement, 'contextmenu', this.delegateContextMenuHandler);
3529
+ this.delegateContextMenuHandler = null;
3530
+ }
3561
3531
  if (!this.isMenu) {
3562
3532
  this.clonedElement.style.display = '';
3563
3533
  if (this.clonedElement.tagName === 'EJS-CONTEXTMENU') {
@@ -3601,7 +3571,31 @@ let MenuBase = class MenuBase extends Component {
3601
3571
  wrapper.parentNode.insertBefore(this.element, wrapper);
3602
3572
  this.clonedElement = null;
3603
3573
  }
3574
+ if (this.popupObj) {
3575
+ this.popupObj.destroy();
3576
+ this.popupObj = null;
3577
+ }
3578
+ this.currentTarget = null;
3579
+ this.targetElement = null;
3580
+ if (this.animation) {
3581
+ this.animation.destroy();
3582
+ this.animation = null;
3583
+ }
3584
+ if (!this.isMenu && !this.isCmenuOpened && this.element) {
3585
+ const elementInstance = getValue('ej2_instances', this.element);
3586
+ if (elementInstance && Array.isArray(elementInstance)) {
3587
+ elementInstance.length = 0;
3588
+ setValue('ej2_instances', elementInstance, this.element);
3589
+ }
3590
+ }
3604
3591
  detach(wrapper);
3592
+ if (this.uList && !document.body.contains(this.uList)) {
3593
+ const ulInstance = getValue('ej2_instances', this.uList);
3594
+ if (ulInstance && Array.isArray(ulInstance)) {
3595
+ ulInstance.length = 0;
3596
+ setValue('ej2_instances', ulInstance, this.uList);
3597
+ }
3598
+ }
3605
3599
  super.destroy();
3606
3600
  if (this.template) {
3607
3601
  this.clearTemplate(['template']);
@@ -3960,17 +3954,13 @@ let Toolbar = class Toolbar extends Component {
3960
3954
  }
3961
3955
  destroyItems() {
3962
3956
  if (this.element) {
3963
- [].slice.call(this.element.querySelectorAll('.' + CLS_ITEM)).forEach((el) => {
3964
- EventHandler.remove(el, 'click', this.itemClick);
3965
- detach(el);
3966
- });
3957
+ [].slice.call(this.element.querySelectorAll('.' + CLS_ITEM)).forEach((el) => { detach(el); });
3967
3958
  }
3968
3959
  if (this.tbarAlign) {
3969
3960
  const tbarItems = this.element.querySelector('.' + CLS_ITEMS);
3970
3961
  if (tbarItems) {
3971
3962
  if (tbarItems.children) {
3972
3963
  [].slice.call(tbarItems.children).forEach((el) => {
3973
- EventHandler.remove(el, 'click', this.itemClick);
3974
3964
  detach(el);
3975
3965
  });
3976
3966
  }
@@ -5698,7 +5688,7 @@ let Toolbar = class Toolbar extends Component {
5698
5688
  dom.setAttribute('aria-label', (item.text || item.tooltipText));
5699
5689
  dom.setAttribute('aria-disabled', 'false');
5700
5690
  innerEle.appendChild(dom);
5701
- EventHandler.add(innerEle, 'click', this.itemClick, this);
5691
+ innerEle.addEventListener('click', this.itemClick.bind(this));
5702
5692
  break;
5703
5693
  case 'Separator':
5704
5694
  this.add(innerEle, CLS_SEPARATOR);