New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No event hook to reposition element #111

Closed
Billy- opened this Issue Mar 11, 2016 · 10 comments

Comments

Projects
None yet
2 participants
@Billy-

Billy- commented Mar 11, 2016

I know you can use an option to affect where the element is poisitioned related to the triggered element. I am trying to position the element dynamically with JS but all of the event hooks take place before the positioning is done, so any styles I add get overwritten.

I think we need an 'after_show' event hook.

Although given the scenario I am not sure what the difference between 'before_show' and 'show' is; considering they both take place before the element is shown.

It is important that you allow the user to do this as they may not want the widget to be positioned relative to the element that triggers it. That element could even be hidden. But the main issue I am having is on a mobile the widget gets positioned partly off the page. Would it also be an idea to add logic to check if the widget is going to positioned outside of the page, and if so, make some adjustments accordingly?

Regards

@nazar-pc

This comment has been minimized.

Owner

nazar-pc commented Mar 11, 2016

You can always wrap datepicker in some div and apply custom positioning for it, while datepicker will just sit inside of it and never actually show/hide itself.

@nazar-pc nazar-pc closed this Mar 23, 2016

@Billy-

This comment has been minimized.

Billy- commented Apr 6, 2016

Sorry I did not see your reply to this before. How would I wrap it as it's dynamically generated? Also would it not still try to position the datepicker with inline styles relative the the input that triggered it?

@nazar-pc

This comment has been minimized.

Owner

nazar-pc commented Apr 6, 2016

If you place it into some div, there will be no direct connection with input, you'll need to establish that connection manually using available events.

@nazar-pc nazar-pc reopened this Apr 6, 2016

@Billy-

This comment has been minimized.

Billy- commented Apr 6, 2016

How can I place it in a div? The datepicker element is generated dynamically from JS?

var $dateInpt = $('.js-date');

if($dateInpt.length) {
  $dateInpt.pickmeup({
    'hide_on_select': true
  });
}
@nazar-pc

This comment has been minimized.

Owner

nazar-pc commented Apr 6, 2016

You have to basically using flat mode, not applying it to input. Like in demo: https://github.com/nazar-pc/PickMeUp/blob/master/js/demo.js#L2

@Billy-

This comment has been minimized.

Billy- commented Apr 6, 2016

Hmm, don't you think it would be nice to have an event fire when the datepicker element is shown so that we can apply position dynamically without having to use the flat mode?

@Billy-

This comment has been minimized.

Billy- commented Apr 6, 2016

Or allow the user to override the positioning function and pass their own function that positions / styles the element? I would be happy to help contribute to this feature

@nazar-pc

This comment has been minimized.

Owner

nazar-pc commented Apr 6, 2016

I'm not sure I'd like to have it right now. The reason is that there are many people with multiple edge-cases and supporting literally all use-cases makes codebase too bloated.
I'm still collecting thoughts and hopefully one day I'll put my hands to fix all existing bugs, release new version and than starting refactoring that will lead to new major version with much better design and more possibilities for customization.

@Billy-

This comment has been minimized.

Billy- commented Apr 6, 2016

Ok. Thanks for your help and I hope you add this feature in in the future - I do think it would be a very useful one. Let me know if you want any help! :)

@nazar-pc

This comment has been minimized.

Owner

nazar-pc commented Feb 12, 2018

I've just published 3.1.0 that supports custom function in position option, so now it is possible to implement arbitrary positioning in generic way

@nazar-pc nazar-pc closed this Feb 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment