Home > widget-integration > RecommendationWidgetController > calcDropdownPosition
RecommendationWidgetController.calcDropdownPosition() method
Calculates and updates the position of open dropdowns based on their trigger elements.
Dynamically repositions open dropdown elements when the page is scrolled or resized to maintain proper alignment with their trigger buttons. Override this method to implement custom positioning logic, add animations, or modify responsive behavior.
Signature:
calcDropdownPosition(): void;
Returns:
void
Remarks
This method is called automatically on scroll and resize events. It updates the inline styles of open dropdown elements to keep them properly positioned.
Example
Override to add smooth positioning animations:
public calcDropdownPosition(): void {
super.calcDropdownPosition();
// Add smooth transition for position changes
const openDropdowns = document.querySelectorAll('.boost-sd__dropdown-option-list--open');
openDropdowns.forEach(dropdown => {
(dropdown as HTMLElement).style.transition = 'all 0.2s ease-in-out';
});
}