Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. var setPosition = function ($targetElement, o, $inf) {
  2. var height = document.body.clientHeight;
  3. var width = document.body.clientWidth;
  4. var offsetLeftposition = $targetElement.offset().left;
  5. var offsetTopposition = $targetElement.offset().top;
  6. var setLeftposition = (width - (offsetLeftposition + 30 + parseFloat(o.width))) > 0 ? offsetLeftposition + 30 :
  7. offsetLeftposition - 10 - parseFloat(o.width) > 0 ? offsetLeftposition - (10 + parseFloat(o.width)) :
  8. offsetLeftposition - (10 + parseFloat(o.width) / 2);
  9. var settopposition = (height - (offsetTopposition + 30 + parseFloat(o.height))) > 0 ? offsetTopposition + 10 :
  10. offsetTopposition - (10 + parseFloat(o.height));
  11. $inf.css('top', settopposition).css('left', setLeftposition);
  12.  
  13. }
  14.  
  15.  
  16.  
  17. any better way to calculate the position and make it responsive?
  18. the div open on click of some image .(it looks like tooltip).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement