Skip to content

Commit

Permalink
prevent magneting
Browse files Browse the repository at this point in the history
  • Loading branch information
SeonMyungLim committed Oct 17, 2016
1 parent 3c62b3b commit 8cf384b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
33 changes: 20 additions & 13 deletions dist/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21858,19 +21858,26 @@ Entry.ExtGuide = function(b, a, d) {
};
(function(b) {
b.render = function() {
var a = this.blockView.getBoard();
this.svgGroup = this.blockView.svgGroup.elem("g", {class:"extension guideGroup"});
this.blockView.guideSvgGroup = this.svgGroup;
$(this.svgGroup).bind("mousedown touchstart", function(a) {
a.stopPropagation && a.stopPropagation();
a.preventDefault && a.preventDefault();
});
var b = this.block.getCode().createThread(this.model);
!b.view && b.createView(a);
this.svgGroup.appendChild(b.getFirstBlock().view.clone());
this.updatePos();
this.block.getThread().view.setHasGuide(!0);
b.destroy(!1);
if (this.model) {
var a = this.blockView.getBoard();
this.svgGroup = this.blockView.svgGroup.elem("g", {class:"extension guideGroup"});
this.blockView.guideSvgGroup = this.svgGroup;
$(this.svgGroup).bind("mousedown touchstart", function(a) {
a.stopPropagation && a.stopPropagation();
a.preventDefault && a.preventDefault();
});
var b = this.block.getCode();
this.model[0].x = -99999;
this.model[0].y = -99999;
b = b.createThread(this.model);
!b.view && b.createView(a);
a = b.getFirstBlock().view.clone();
a.removeAttribute("transform");
this.svgGroup.appendChild(a);
this.updatePos();
this.block.getThread().view.setHasGuide(!0);
b.destroy(!1);
}
};
b.updatePos = function() {
this.svgGroup.attr("transform", this._getTransform());
Expand Down
4 changes: 2 additions & 2 deletions dist/entry.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/workspace/extension/guide.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Entry.ExtGuide = function(content, blockView, mode) {
};

(function(p) {
var TRANSFORM = "transform";
p.render = function() {
if (!this.model) return;

var board = this.blockView.getBoard();
this.svgGroup = this.blockView.svgGroup.elem("g", {
class: 'extension guideGroup'
Expand All @@ -27,16 +30,24 @@ Entry.ExtGuide = function(content, blockView, mode) {

var block = this.block;
var code = block.getCode();

//move blocks off the screen
//in order to prevent magneting for some reasons
this.model[0].x = -99999;
this.model[0].y = -99999;

var thread = code.createThread(this.model);
!thread.view && thread.createView(board);
this.svgGroup.appendChild(thread.getFirstBlock().view.clone());
var cloned = thread.getFirstBlock().view.clone();
cloned.removeAttribute(TRANSFORM);
this.svgGroup.appendChild(cloned);
this.updatePos();
this.block.getThread().view.setHasGuide(true);
thread.destroy(false);
};

p.updatePos = function() {
this.svgGroup.attr('transform', this._getTransform());
this.svgGroup.attr(TRANSFORM, this._getTransform());
};

p._getTransform = function() {
Expand Down

0 comments on commit 8cf384b

Please sign in to comment.