Commit d83f5872 authored by Neil Fraser's avatar Neil Fraser

Don't allow snapping to grid with 0 spacing.

parent 4b550b9d
...@@ -1323,7 +1323,7 @@ Blockly.WidgetDiv.position=function(a,b,c,d,e){b<d.y&&(b=d.y);e?a>c.width+d.x&&( ...@@ -1323,7 +1323,7 @@ Blockly.WidgetDiv.position=function(a,b,c,d,e){b<d.y&&(b=d.y);e?a>c.width+d.x&&(
Blockly.inject=function(a,b){goog.isString(a)&&(a=document.getElementById(a));if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";var c=Blockly.parseOptions_(b||{}),d,e=function(){goog.dom.removeChildren(a);var b=Blockly.createDom_(a,c);d=Blockly.createMainWorkspace_(b,c);Blockly.init_(d);d.markFocused();Blockly.bindEvent_(b,"focus",d,d.markFocused)};if(c.enableRealtime){var f=document.getElementById("realtime");f&&(f.style.display="block");Blockly.Realtime.startRealtime(e, Blockly.inject=function(a,b){goog.isString(a)&&(a=document.getElementById(a));if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";var c=Blockly.parseOptions_(b||{}),d,e=function(){goog.dom.removeChildren(a);var b=Blockly.createDom_(a,c);d=Blockly.createMainWorkspace_(b,c);Blockly.init_(d);d.markFocused();Blockly.bindEvent_(b,"focus",d,d.markFocused)};if(c.enableRealtime){var f=document.getElementById("realtime");f&&(f.style.display="block");Blockly.Realtime.startRealtime(e,
a,c.realtimeOptions)}else e();return d};Blockly.parseToolboxTree_=function(a){a?("string"!=typeof a&&"undefined"==typeof XSLTProcessor&&(a=a.outerHTML),"string"==typeof a&&(a=Blockly.Xml.textToDom(a))):a=null;return a}; a,c.realtimeOptions)}else e();return d};Blockly.parseToolboxTree_=function(a){a?("string"!=typeof a&&"undefined"==typeof XSLTProcessor&&(a=a.outerHTML),"string"==typeof a&&(a=Blockly.Xml.textToDom(a))):a=null;return a};
Blockly.parseOptions_=function(a){var b=!!a.readOnly;if(b)var c=null,d=!1,e=!1,f=!1,g=!1,h=!1,k=!1;else c=Blockly.parseToolboxTree_(a.toolbox),d=Boolean(c&&c.getElementsByTagName("category").length),e=a.trashcan,void 0===e&&(e=d),f=a.collapse,void 0===f&&(f=d),g=a.comments,void 0===g&&(g=d),h=a.disable,void 0===h&&(h=d),k=a.sounds,void 0===k&&(k=!0);var l=a.scrollbars;void 0===l&&(l=d);var p=a.css;void 0===p&&(p=!0);var m=a.grid||{};m.spacing=m.spacing?parseFloat(m.spacing):0;m.colour||(m.colour= Blockly.parseOptions_=function(a){var b=!!a.readOnly;if(b)var c=null,d=!1,e=!1,f=!1,g=!1,h=!1,k=!1;else c=Blockly.parseToolboxTree_(a.toolbox),d=Boolean(c&&c.getElementsByTagName("category").length),e=a.trashcan,void 0===e&&(e=d),f=a.collapse,void 0===f&&(f=d),g=a.comments,void 0===g&&(g=d),h=a.disable,void 0===h&&(h=d),k=a.sounds,void 0===k&&(k=!0);var l=a.scrollbars;void 0===l&&(l=d);var p=a.css;void 0===p&&(p=!0);var m=a.grid||{};m.spacing=m.spacing?parseFloat(m.spacing):0;m.colour||(m.colour=
"#888");m.length=m.length?parseFloat(m.length):1;m.snap=!!m.snap;var q="https://blockly-demo.appspot.com/static/media/";a.media?q=a.media:a.path&&(q=a.path+"media/");var n=!!a.realtime;return{RTL:!!a.rtl,collapse:f,comments:g,disable:h,readOnly:b,maxBlocks:a.maxBlocks||Infinity,pathToMedia:q,hasCategories:d,hasScrollbars:l,hasTrashcan:e,hasSounds:k,hasCss:p,languageTree:c,gridOptions:m,enableRealtime:n,realtimeOptions:n?a.realtimeOptions:void 0}}; "#888");m.length=m.length?parseFloat(m.length):1;m.snap=0<m.spacing&&!!m.snap;var q="https://blockly-demo.appspot.com/static/media/";a.media?q=a.media:a.path&&(q=a.path+"media/");var n=!!a.realtime;return{RTL:!!a.rtl,collapse:f,comments:g,disable:h,readOnly:b,maxBlocks:a.maxBlocks||Infinity,pathToMedia:q,hasCategories:d,hasScrollbars:l,hasTrashcan:e,hasSounds:k,hasCss:p,languageTree:c,gridOptions:m,enableRealtime:n,realtimeOptions:n?a.realtimeOptions:void 0}};
Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},a),d=Blockly.createSvgElement("defs",{},c),e,f;e=Blockly.createSvgElement("filter",{id:"blocklyEmboss"},d);Blockly.createSvgElement("feGaussianBlur",{"in":"SourceAlpha", Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},a),d=Blockly.createSvgElement("defs",{},c),e,f;e=Blockly.createSvgElement("filter",{id:"blocklyEmboss"},d);Blockly.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",
stdDeviation:1,result:"blur"},e);f=Blockly.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e);Blockly.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},f);Blockly.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e);Blockly.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e);e=Blockly.createSvgElement("filter", stdDeviation:1,result:"blur"},e);f=Blockly.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e);Blockly.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},f);Blockly.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e);Blockly.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e);e=Blockly.createSvgElement("filter",
{id:"blocklyShadowFilter"},d);Blockly.createSvgElement("feGaussianBlur",{stdDeviation:2},e);e=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern",patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},e);Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},e);e=b.gridOptions.spacing||100;d=Blockly.createSvgElement("pattern",{id:"blocklyGridPattern"+String(Math.random()).substring(2),patternUnits:"userSpaceOnUse", {id:"blocklyShadowFilter"},d);Blockly.createSvgElement("feGaussianBlur",{stdDeviation:2},e);e=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern",patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},e);Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},e);e=b.gridOptions.spacing||100;d=Blockly.createSvgElement("pattern",{id:"blocklyGridPattern"+String(Math.random()).substring(2),patternUnits:"userSpaceOnUse",
......
...@@ -157,7 +157,7 @@ Blockly.parseOptions_ = function(options) { ...@@ -157,7 +157,7 @@ Blockly.parseOptions_ = function(options) {
} else { } else {
grid['length'] = parseFloat(grid['length']); grid['length'] = parseFloat(grid['length']);
} }
grid['snap'] = !!grid['snap']; grid['snap'] = grid['spacing'] > 0 && !!grid['snap'];
var pathToMedia = 'https://blockly-demo.appspot.com/static/media/'; var pathToMedia = 'https://blockly-demo.appspot.com/static/media/';
if (options['media']) { if (options['media']) {
pathToMedia = options['media']; pathToMedia = options['media'];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment