Skip to content
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

Message not centered in jQuery-ui Tabs #138

Open
marmz opened this issue Jun 15, 2017 · 4 comments
Open

Message not centered in jQuery-ui Tabs #138

marmz opened this issue Jun 15, 2017 · 4 comments

Comments

@marmz
Copy link

marmz commented Jun 15, 2017

When using block() on elements contained in jQuery Tabs, we have wrong centering.
Here's an example:

http://www.codipe.it/mzweb/test/blocktabs.php

Now try to navigate through Tabs ...
As you can see, in the 1st Tab the "Please wait" message is well centered.
Instead, in all other Tabs, it goes to the upper-left corner of the blocked DIV.

The problem does not extend to the dark overlay, which covers exactly the space of the blocked DIV.

I hope this project is still maintained and someone read this ;)

@CZEMacLeod
Copy link

I, too, have had this issue for ages, but have just put up with it. I hope someone can help!

@marmz
Copy link
Author

marmz commented Jun 16, 2017

For now the only "workaround" i found is to set:

$.blockUI.defaults.centerX = false;
$.blockUI.defaults.centerY = false;

But then you must adjust top/left coords. manually ... Not a really flexible solution!

We should find the best "centering" paradigm, then modify the center(el, x, y) function inside blockUi code :/

Let me know if you go farther in this .. I'll do the same! ;)

@mafar
Copy link

mafar commented Mar 28, 2018

This is what I use for hidden divs (tab-pane not active is hidden). since divs are hidden, message is not centered.
Only caveat of this solution is , it is centered horizontally not vertically
https://jsfiddle.net/bababalcksheep/4kc3sg6e/59/

        centerX:false,
        centerY:false,
         'css': {
           'border': '0',
           'padding': '0',
           'width': '100%',
           'height': '100%',
           'top': '0',
           'left': '0',
         },
         'overlayCSS': {
           'backgroundColor': '#000',
           'opacity': 0.1,
           'cursor': 'wait'
         }

@mafar
Copy link

mafar commented Mar 28, 2018

https://jsfiddle.net/bababalcksheep/4kc3sg6e/83/

  //  uses https://github.com/dreamerslab/jquery.actual
  // to center message block
  function center(el) {
    var parentNode = el.parent();
    var parentNode_BLW = parseInt(parentNode.css('border-left-width'), 10) || 0;
    var parentNode_BTW = parseInt(parentNode.css('border-top-width'), 10) || 0;
    var left = ((parentNode.actual('outerWidth') - el.actual('outerWidth')) / 2) - parentNode_BLW;
    var top = ((parentNode.actual('outerHeight') - el.actual('outerHeight')) / 2) - parentNode_BTW;
    el.css('left', left > 0 ? (left + 'px') : '0');
    el.css('top', top > 0 ? (top + 'px') : '0');
  }

You can use this function and you can use it on windows resize or tab shown event or even onBLock event.
see fiddle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants