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';
	}
}

Register

You will be emailed a link to set your password.

Login

Lost password?