Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

Reply To: Centering dropdown in relation to parent

Home Forums Older releases 1.0.x + Bootstrap addon Centering dropdown in relation to parent Reply To: Centering dropdown in relation to parent

#3384
suzyb
Participant

I was wrong about the offset used, it’s mainMenuSubOffsetX that does the correct thing.

I managed to come up with a solution that seems to work. The following code I added after the ‘hide.smapi’ binding in the jquery.smartmenus.bootstrap.js file.

'beforeshow.smapi': function (e, menu) {
	var $menu = $(menu), obj = $(this).data('smartmenus');

	obj.opts.mainMenuSubOffsetX = 0;    // reset so it isn't held over between different dropdowns

	var width = obj.getWidth($menu.dataSM('parent-a'));
	var subWidth = obj.getWidth($menu);

	if (subWidth > width) {
		obj.opts.mainMenuSubOffsetX = -Math.abs((subWidth - width) / 2) + 'px';
	}
}