code_junkie

Position div depending on distance browser edge (javascript)

Nov 14th, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. var $doc = $(document),
  2. $win = $(window),
  3. $this = $('#mydiv'),
  4. offset = $this.offset(),
  5. dTop = offset.top - $doc.scrollTop(),
  6. dBottom = $win.height() - dTop - $this.height(),
  7. dLeft = offset.left - $doc.scrollLeft(),
  8. dRight = $win.width() - dLeft - $this.width();
Add Comment
Please, Sign In to add comment