Skip to content
This repository has been archived by the owner on Oct 3, 2018. It is now read-only.

Commit

Permalink
[html] When zooming a tooltip, bump the window scroll to keep it onsc…
Browse files Browse the repository at this point in the history
…reen if possible
  • Loading branch information
Nephyrin committed Mar 24, 2012
1 parent 9be91f2 commit e2dd1ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions html/slimyet.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ Tooltip.prototype.zoom = function(callback) {
var w = this.obj.parent().width();
var h = this.obj.parent().height();

// If the parent is offscreen, try to bump it on screen if we can
var offset = this.obj.parent().offset();
var scrolltop = $('html').scrollTop();
var scroll = scrolltop;

if (scroll + window.innerHeight < offset.top + h)
scroll = offset.top - (window.innerHeight - h) + 20;
if (scroll > offset.top)
scroll = offset.top - 20;

if (scroll != scrolltop) {
logMsg('Scrolling to '+scroll);
$('html').animate({ 'scrollTop' : scroll }, 500);
}

this.obj.show();
this.obj.stop().addClass('zoomed').animate({
width: '94%',
Expand Down

0 comments on commit e2dd1ab

Please sign in to comment.