Skip to content

Commit

Permalink
Stop Firefox from jumping when widget div is displayed. Issue 186.
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilFraser committed Oct 2, 2015
1 parent 6f924e3 commit 2d11522
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/widgetdiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ goog.provide('Blockly.WidgetDiv');

goog.require('Blockly.Css');
goog.require('goog.dom');
goog.require('goog.style');


/**
Expand Down Expand Up @@ -75,6 +76,10 @@ Blockly.WidgetDiv.show = function(newOwner, rtl, dispose) {
Blockly.WidgetDiv.hide();
Blockly.WidgetDiv.owner_ = newOwner;
Blockly.WidgetDiv.dispose_ = dispose;
// Temporarily move the widget to the top of the screen so that it does not
// cause a scrollbar jump in Firefox when displayed.
var xy = goog.style.getViewportPageOffset(document);
Blockly.WidgetDiv.DIV.style.top = xy.y + 'px';
Blockly.WidgetDiv.DIV.style.direction = rtl ? 'rtl' : 'ltr';
Blockly.WidgetDiv.DIV.style.display = 'block';
};
Expand Down
4 changes: 2 additions & 2 deletions tests/playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
{enabled: true,
controls: true,
wheel: true,
maxScale: 2,
minScale: .1,
maxScale: 4,
minScale: .25,
scaleSpeed: 1.1
},
});
Expand Down

0 comments on commit 2d11522

Please sign in to comment.