Guest User

Untitled

a guest
Aug 7th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $.fn.fullCenter = function() {
  2. return this.each(function() {
  3. var $el = $(this);
  4. $.fn.fullCenter.center($el);
  5. })
  6. }
  7. $.fn.fullCenter.center = function($el) {
  8. console.log($el);
  9. console.log("$el.outerHeight(): " + $el.outerHeight());
  10. console.log("$el.outerWidth(): " + $el.outerWidth());
  11. console.log("$el[0].scrollHeight: " + $el[0].scrollHeight);
  12. // Change the margin-top and margin-left
  13. if($el.data('center')) {
  14. var params = $el.data('center').split(" ");
  15.  
  16. if(params.indexOf('vertical') != -1) {
  17. $el.css({
  18. 'margin-top': '-' + ($el.outerHeight() / 2) + 'px'
  19. })
  20. }
  21. if(params.indexOf('horizontal') != -1) {
  22. $el.css({
  23. 'margin-left': '-' + ($el.outerWidth() / 2) + 'px'
  24. })
  25. }
  26. } else {
  27. $el.css({
  28. 'margin-left': '-' + ($el.outerWidth() / 2) + 'px',
  29. 'margin-top': '-' + ($el.outerHeight() / 2) + 'px'
  30. })
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment