soundasleep / jquery-dropdown

Bootstrap-style dropdowns with some added features and no dependencies.
Other
767 stars 268 forks source link

Add optional horizontal and vertical offsets to the menu position. #10

Closed dendrochronology closed 11 years ago

dendrochronology commented 11 years ago

Much in the spirit of this plugin, I wanted to add a jquery-dropdown to an existing project, with much cruft and bloaty CSS. The positioning was a bit off, and unraveling the existing CSS would affect the other elements around the trigger. Thus, the data-dropdown-h-offset and data-dropdown-v-offset attributes. Add them to the trigger element, and they'll shift the positioning by a few pixels one way or the other.

This request also includes an amended readme file.

dendrochronology commented 11 years ago

It was probably possible, but really, really yucky. My thought was this: 99% of the time, style mods are the way to go. However, really complex layouts that are already accounting for lots of elements with various margins, paddings, etc., can totally make your head explode. I thought offsets could work something like the "bias" knob on old analog recorders. Yes, you could fix the issue in the source material, but that can be more trouble (or do more damage) than it's worth. The error is baked in, so you just correct for it on playback.

It seems to me that the genesis of jquery-dropdown came out of retrofitting designs where you want to leave much of what's there intact, to avoid introduction of regressions (my project has dozens of stylesheets, from several different vendors). If the positioning gets a little confused by kludgey, negative-margin hacks, then just correct for it with a touch of positive or negative offset.

claviska commented 11 years ago

I'm going to accept this with a couple of minor tweaks. I'll push the results in a few minutes...