Skip to content

Commit 9d79e2d

Browse files
committed
feat(filters): use offset left to calculate auto position (left/right)
- use the offseft left position to properly calculate the available space instead of the scroll left position
1 parent b0bc379 commit 9d79e2d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/assets/lib/multiple-select/multiple-select.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @author zhixin wen <wenzhixin2010@gmail.com>
3-
* @version 1.3.9
3+
* @version 1.3.10
44
*
55
* http://wenzhixin.net.cn/p/multiple-select/
66
*
@@ -631,9 +631,9 @@
631631
var msDropHeight = this.$drop.outerHeight() || 0;
632632
var msDropWidth = this.$drop.outerWidth() || 0;
633633
var selectOffsetTop = this.$parent.offset().top;
634+
var selectOffsetLeft = this.$parent.offset().left;
634635
var selectParentWidth = this.$parent.width();
635636
var spaceBottom = this.availableSpaceBottom();
636-
var spaceLeft = this.availableSpaceLeft();
637637
var spaceTop = this.availableSpaceTop();
638638
var windowWidth = $(window).width();
639639

@@ -662,8 +662,8 @@
662662
}
663663

664664
// auto-adjust left/right position
665-
if ((windowWidth - msDropWidth) < spaceLeft) {
666-
var newLeftOffset = spaceLeft - (msDropWidth - selectParentWidth);
665+
if ((windowWidth - msDropWidth) < selectOffsetLeft) {
666+
var newLeftOffset = selectOffsetLeft - (msDropWidth - selectParentWidth);
667667
this.$drop.offset({ left: newLeftOffset });
668668
}
669669

@@ -725,12 +725,6 @@
725725
return windowHeight - (msDropOffsetTop - pageScroll);
726726
},
727727

728-
availableSpaceLeft: function () {
729-
var pageScrollLeft = $(window).scrollLeft() || 0;
730-
var msDropOffsetLeft = this.$parent.offset().left;
731-
return msDropOffsetLeft - pageScrollLeft;
732-
},
733-
734728
availableSpaceTop: function () {
735729
var pageScroll = $(window).scrollTop() || 0;
736730
var msDropOffsetTop = this.$parent.offset().top;

0 commit comments

Comments
 (0)