mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Merge pull request #534 from picklesrus/develop-screenctm-bugs
Fix for #498. Recalculate the things that use screen coordinates (de…
This commit is contained in:
commit
c7dea98e88
2 changed files with 37 additions and 3 deletions
|
@ -533,6 +533,7 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
|
|||
if (this.isInFlyout) {
|
||||
return;
|
||||
}
|
||||
this.workspace.updateScreenCalculationsIfScrolled();
|
||||
this.workspace.markFocused();
|
||||
Blockly.terminateDrag_();
|
||||
this.select();
|
||||
|
|
|
@ -147,6 +147,15 @@ Blockly.WorkspaceSvg.prototype.scrollbar = null;
|
|||
*/
|
||||
Blockly.WorkspaceSvg.prototype.lastSound_ = null;
|
||||
|
||||
/**
|
||||
* Last known position of the page scroll.
|
||||
* This is used to determine whether we have recalculated screen coordinate
|
||||
* stuff since the page scrolled.
|
||||
* @type {!goog.math.Coordinate}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.lastRecordedPageScroll_ = null;
|
||||
|
||||
/**
|
||||
* Inverted screen CTM, for use in mouseToSvg.
|
||||
* @type {SVGMatrix}
|
||||
|
@ -344,6 +353,16 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function() {
|
|||
this.svgGroup_.insertBefore(svgFlyout, this.svgBlockCanvas_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Update items that use screen coordinate calculations
|
||||
* because something has changed (e.g. scroll position, window size).
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.updateScreenCalculations_ = function() {
|
||||
this.updateInverseScreenCTM();
|
||||
this.recordDeleteAreas();
|
||||
};
|
||||
|
||||
/**
|
||||
* Resize the parts of the workspace that change when the workspace
|
||||
* contents (e.g. block positions) change. This will also scroll the
|
||||
|
@ -383,11 +402,25 @@ Blockly.WorkspaceSvg.prototype.resize = function() {
|
|||
if (this.scrollbar) {
|
||||
this.scrollbar.resize();
|
||||
}
|
||||
|
||||
this.updateInverseScreenCTM();
|
||||
this.recordDeleteAreas();
|
||||
this.updateScreenCalculations_();
|
||||
};
|
||||
|
||||
/**
|
||||
* Resizes and repositions workspace chrome if the page has a new
|
||||
* scroll position.
|
||||
* @package
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled
|
||||
= function() {
|
||||
/* eslint-disable indent */
|
||||
var currScroll = goog.dom.getDocumentScroll();
|
||||
if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_,
|
||||
currScroll)) {
|
||||
this.lastRecordedPageScroll_ = currScroll;
|
||||
this.updateScreenCalculations_();
|
||||
}
|
||||
}; /* eslint-enable indent */
|
||||
|
||||
/**
|
||||
* Get the SVG element that forms the drawing surface.
|
||||
* @return {!Element} SVG element.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue