slick-components 17.0.18 → 17.0.20

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.
@@ -23,7 +23,7 @@ class SlickInitParams {
23
23
  }
24
24
  }
25
25
  class SlickInitService {
26
- static { this.version = "17.0.18"; }
26
+ static { this.version = "17.0.20"; }
27
27
  constructor() { }
28
28
  static init(initParams) {
29
29
  console.info(`Slick Components Version ${SlickInitService.version}`);
@@ -3457,6 +3457,8 @@ class SlickDropListDirective {
3457
3457
  this.fnMouseDown = (e) => this.mouseDown(e);
3458
3458
  this.fnMouseMove = (e) => this.mouseMove(e);
3459
3459
  this.fnMouseUp = () => this.mouseUp();
3460
+ this.fnMouseOver = (e) => this.mouseOver(e);
3461
+ this.isScrolling = false;
3460
3462
  this.el = el.nativeElement;
3461
3463
  this.el.setAttribute("drop-list-uuid", this.uuid);
3462
3464
  }
@@ -3468,6 +3470,18 @@ class SlickDropListDirective {
3468
3470
  document.removeEventListener("mousedown", this.fnMouseDown, true);
3469
3471
  document.removeEventListener("mousemove", this.fnMouseMove, true);
3470
3472
  document.removeEventListener("mouseup", this.fnMouseUp, true);
3473
+ document.removeEventListener("mouseover", this.fnMouseOver, true);
3474
+ }
3475
+ mouseOver(e) {
3476
+ const currentTarget = e.target;
3477
+ // Find the parent with 'drop-list-uuid' attribute and check if it matches
3478
+ const parent = SlickUtilsService.findParentByAttr(currentTarget, 'drop-list-uuid', this.uuid);
3479
+ if (!parent) {
3480
+ if (this.isScrolling) {
3481
+ this.stopAutoScrolling();
3482
+ return;
3483
+ }
3484
+ }
3471
3485
  }
3472
3486
  async mouseDown(e, target = null) {
3473
3487
  this.isAdding = false;
@@ -3476,6 +3490,7 @@ class SlickDropListDirective {
3476
3490
  return;
3477
3491
  document.removeEventListener("mouseup", this.fnMouseUp, true);
3478
3492
  document.removeEventListener("mousemove", this.fnMouseMove, true);
3493
+ document.removeEventListener("mouseover", this.fnMouseOver, true);
3479
3494
  document.addEventListener("mouseup", this.fnMouseUp, true);
3480
3495
  document.addEventListener("mousemove", this.fnMouseMove, true);
3481
3496
  if (!target)
@@ -3487,6 +3502,7 @@ class SlickDropListDirective {
3487
3502
  if (grabEls.length > 0 && !SlickUtilsService.findParent(target, "slick-drop-list-grab"))
3488
3503
  return true;
3489
3504
  this.isMoving = true;
3505
+ document.addEventListener("mouseover", this.fnMouseOver, true);
3490
3506
  const dropListItem = SlickUtilsService.findParent(target, "slick-drop-list-item");
3491
3507
  if (!dropListItem) {
3492
3508
  console.error("Can't find item element");
@@ -3530,6 +3546,23 @@ class SlickDropListDirective {
3530
3546
  this.onSlickDropListEnter.emit({ idx: idx, ready: this.newItemReady.bind(this) });
3531
3547
  return;
3532
3548
  }
3549
+ // Handle auto-scrolling
3550
+ this.handleAutoScroll(e);
3551
+ // Handle redrawing selected item
3552
+ this.handleRedraw(e);
3553
+ }
3554
+ getScrollableParent(element) {
3555
+ let parent = element.parentElement;
3556
+ while (parent) {
3557
+ const overflowY = window.getComputedStyle(parent).overflowY;
3558
+ if (overflowY === 'auto' || overflowY === 'scroll') {
3559
+ return parent; // Found a scrollable parent
3560
+ }
3561
+ parent = parent.parentElement;
3562
+ }
3563
+ return null; // No scrollable parent found
3564
+ }
3565
+ handleRedraw(e) {
3533
3566
  // Find which element the mouse is over
3534
3567
  const dropListItems = this.el.querySelectorAll(".slick-drop-list-item");
3535
3568
  for (let i = 0; i < dropListItems.length; i++) {
@@ -3551,9 +3584,62 @@ class SlickDropListDirective {
3551
3584
  }
3552
3585
  }
3553
3586
  }
3587
+ handleAutoScroll(e) {
3588
+ const scrollMargin = 50; // Distance from the top/bottom to trigger scrolling
3589
+ const scrollableParent = this.getScrollableParent(e.target);
3590
+ if (!scrollableParent)
3591
+ return;
3592
+ const parentRect = scrollableParent.getBoundingClientRect();
3593
+ const offsetY = e.clientY - parentRect.top; // Mouse position relative to container
3594
+ const scrollTop = scrollableParent.scrollTop;
3595
+ const maxScroll = scrollableParent.scrollHeight - scrollableParent.clientHeight;
3596
+ // Determine if scrolling should occur
3597
+ let scrollDirection = 0;
3598
+ if (offsetY < scrollMargin && scrollTop > 0) {
3599
+ scrollDirection = -1; // Scroll up
3600
+ }
3601
+ else if (offsetY > parentRect.height - scrollMargin && scrollTop < maxScroll) {
3602
+ scrollDirection = 1; // Scroll down
3603
+ }
3604
+ if (scrollDirection !== 0) {
3605
+ if (!this.isScrolling) {
3606
+ this.isScrolling = true;
3607
+ this.startAutoScrolling(scrollableParent, e, scrollDirection);
3608
+ }
3609
+ }
3610
+ else {
3611
+ this.stopAutoScrolling();
3612
+ }
3613
+ }
3614
+ startAutoScrolling(scrollableParent, e, direction) {
3615
+ const scrollSpeed = 10; // Base scroll speed
3616
+ const scroll = () => {
3617
+ if (!this.isScrolling)
3618
+ return;
3619
+ const scrollTop = scrollableParent.scrollTop;
3620
+ const maxScroll = scrollableParent.scrollHeight - scrollableParent.clientHeight;
3621
+ // Stop scrolling if we've reached the limits
3622
+ if ((direction === -1 && scrollTop <= 0) || (direction === 1 && scrollTop >= maxScroll)) {
3623
+ this.stopAutoScrolling();
3624
+ return;
3625
+ }
3626
+ // Perform the scroll
3627
+ scrollableParent.scrollBy(0, direction * scrollSpeed);
3628
+ // Continue scrolling if the mouse is still near the edge
3629
+ requestAnimationFrame(scroll);
3630
+ // Keep redrawing while we are scrolling so it doesnt look laggy
3631
+ this.handleRedraw(e);
3632
+ };
3633
+ requestAnimationFrame(scroll);
3634
+ }
3635
+ stopAutoScrolling() {
3636
+ this.isScrolling = false;
3637
+ }
3554
3638
  mouseUp() {
3555
3639
  document.removeEventListener("mouseup", this.fnMouseUp, true);
3556
3640
  document.removeEventListener("mousemove", this.fnMouseMove, true);
3641
+ document.removeEventListener("mouseover", this.fnMouseOver, true);
3642
+ this.stopAutoScrolling();
3557
3643
  if (!this.isMoving)
3558
3644
  return;
3559
3645
  this.isMoving = false;