midnight.js icon indicating copy to clipboard operation
midnight.js copied to clipboard

Request: onComplete callback

Open justinmetros opened this issue 10 years ago • 2 comments

Cool plugin, thanks!

Just a thought, might be nice to have some sort of onComplete() callback once the plugin initializes and does its thing.

With multiple headers, its possible to see a flash of the default element before the appropriately styled element kicks in.

With a callback to signify midnight.js completed its task, it would be a cinch to remove any classes added to initially hide the undesired elements. Will fork if I can find some time. Thanks again!

justinmetros avatar Dec 11 '14 00:12 justinmetros

@justinmetros If you want to do a fork, you should check out the 1.1 branch. The plugin is being refactored to support public methods (as well as cleaning up the code a bit). Callbacks are coming, so a PR would be quite welcome there (mostly to notify users when a header changes).

The main workaround for that issue is to add visibility:hidden to the header (via CSS -don't use display:none, since it'll break the plugin-) and remove it just after the $('header').midnight() call. That way the header won't flash on startup under most scenarios.

Thanks!

RobertoGonzalez avatar Dec 11 '14 00:12 RobertoGonzalez

Great, thanks for quick reply!

Will try to get that PR in off 1.1.

In the meantime the workaround you mention is the exact solution I put in place and it gets the job done.

justinmetros avatar Dec 11 '14 01:12 justinmetros