Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/dropdownToggle/dropdownToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ angular.module('mm.foundation.dropdownToggle', [ 'mm.foundation.position', 'mm.f
var left = Math.round(offset.left - parentOffset.left);
var rightThreshold = $window.innerWidth - dropdownWidth - 8;
if (left > rightThreshold) {
left = rightThreshold;
left = left - dropdownWidth + $position.position(element).width;
dropdown.removeClass('left').addClass('right');
}
css.left = left + 'px';
Expand Down Expand Up @@ -90,6 +90,16 @@ angular.module('mm.foundation.dropdownToggle', [ 'mm.foundation.position', 'mm.f
}
};
$document.on('click', closeMenu);

angular.element($window).bind('resize', function() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you use bind() here instead of on() like the rest of the event listeners?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason for bind(), changing.
Also, added cleanup on $destroy as suggested.

if (!!openElement) {
var left = $position.position(element).left;
if (dropdown.hasClass('right')) {
left = left - dropdownWidth + $position.position(element).width;
}
dropdown.css('left', left);
}
});
}
};

Expand Down