mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Do not nullify inverseScreenCTM if for some reason CTM is lost
This commit is contained in:
@@ -272,9 +272,3 @@ Blockly.RENAME_VARIABLE_ID = 'RENAME_VARIABLE_ID';
|
||||
* @const {string}
|
||||
*/
|
||||
Blockly.DELETE_VARIABLE_ID = 'DELETE_VARIABLE_ID';
|
||||
|
||||
/**
|
||||
* A constant value that we can use to mark calculated properties as dirty.
|
||||
* @const {string}
|
||||
*/
|
||||
Blockly.DIRTY = 'dirty';
|
||||
|
||||
@@ -298,7 +298,14 @@ Blockly.WorkspaceSvg.prototype.targetWorkspace = null;
|
||||
* @type {SVGMatrix}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.inverseScreenCTM_ = Blockly.DIRTY;
|
||||
Blockly.WorkspaceSvg.prototype.inverseScreenCTM_ = null;
|
||||
|
||||
/**
|
||||
* Inverted screen CTM is dirty, recalculate it.
|
||||
* @type {Boolean}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.inverseScreenCTMDirty_ = true;
|
||||
|
||||
/**
|
||||
* Getter for the inverted screen CTM.
|
||||
@@ -308,13 +315,11 @@ Blockly.WorkspaceSvg.prototype.getInverseScreenCTM = function() {
|
||||
|
||||
// Defer getting the screen CTM until we actually need it, this should
|
||||
// avoid forced reflows from any calls to updateInverseScreenCTM.
|
||||
if (this.inverseScreenCTM_ == Blockly.DIRTY) {
|
||||
if (this.inverseScreenCTMDirty_) {
|
||||
var ctm = this.getParentSvg().getScreenCTM();
|
||||
if (ctm) {
|
||||
this.inverseScreenCTM_ = ctm.inverse();
|
||||
} else {
|
||||
// When dirty, and we can't get a CTM, set it to null.
|
||||
this.inverseScreenCTM_ = null;
|
||||
this.inverseScreenCTMDirty_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +330,7 @@ Blockly.WorkspaceSvg.prototype.getInverseScreenCTM = function() {
|
||||
* Mark the inverse screen CTM as dirty.
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.updateInverseScreenCTM = function() {
|
||||
this.inverseScreenCTM_ = Blockly.DIRTY;
|
||||
this.inverseScreenCTMDirty_ = true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user