Skip to content

Commit

Permalink
Merge pull request #490 from entrylabs/issue/endBlock
Browse files Browse the repository at this point in the history
Issue/endBlock
  • Loading branch information
chanlee authored Oct 19, 2016
2 parents 1b7c230 + e71f4c1 commit 4267556
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 63 deletions.
54 changes: 29 additions & 25 deletions dist/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21178,7 +21178,7 @@ Entry.BlockView.pngMap = {};
b._updateBG = function() {
if (this._board.dragBlock && this._board.dragBlock.dragInstance) {
var a = this.svgGroup;
if (this.magnet.next) {
if (this.magnet.next || this.magnet.previous) {
if (a = this.magneting) {
var b = this._board.dragBlock.getShadow(), c = this.getAbsoluteCoordinate(), e;
if ("previous" === a) {
Expand Down Expand Up @@ -21250,15 +21250,17 @@ Entry.BlockView.pngMap = {};
c._moveBy(a, a, !1);
}, b) : c._moveBy(a, a, !1);
};
b.bindPrev = function(a) {
b.bindPrev = function(a, b) {
if (a) {
if (this._toLocalCoordinate(a.view._nextGroup), (a = a.getNextBlock()) && a !== this.block) {
var b = this.block.getLastBlock();
b.view.magnet.next ? a.view._toLocalCoordinate(b.view._nextGroup) : (a.view._toGlobalCoordinate(), a.separate(), a.view.bumpAway(null, 100));
this._toLocalCoordinate(a.view._nextGroup);
var c = a.getNextBlock();
if (c && c && c !== this.block) {
var e = this.block.getLastBlock();
b ? c.view._toLocalCoordinate(a.view._nextGroup) : e.view.magnet.next ? c.view._toLocalCoordinate(e.view._nextGroup) : (c.view._toGlobalCoordinate(), c.separate(), c.view.bumpAway(null, 100));
}
} else {
if (a = this.block.getPrevBlock()) {
this._toLocalCoordinate(a.view._nextGroup), (a = this.block.getNextBlock()) && a.view && a.view._toLocalCoordinate(this._nextGroup);
this._toLocalCoordinate(a.view._nextGroup), (c = this.block.getNextBlock()) && c.view && c.view._toLocalCoordinate(this._nextGroup);
}
}
};
Expand Down Expand Up @@ -23521,25 +23523,28 @@ Entry.Board.DRAG_RADIUS = 5;
this.workspace.setMode(Entry.Workspace.MODE_BOARD, "save");
};
b.generateCodeMagnetMap = function() {
var a = this.code;
if (a && this.dragBlock) {
for (var b in this.dragBlock.magnet) {
var c = this._getCodeBlocks(a, b);
c.sort(function(a, b) {
return a.point - b.point;
});
c.unshift({point:-Number.MAX_VALUE, blocks:[]});
for (var e = 1;e < c.length;e++) {
var f = c[e], g = f, h = f.startBlock;
if (h) {
for (var k = f.endPoint, l = e;k > g.point && (g.blocks.push(h), l++, g = c[l], g);) {
var a = this.code, b = this.dragBlock;
if (a && b) {
this._magnetMap = {};
for (var c in b.magnet) {
if ("next" !== c || void 0 !== b.block.getLastBlock().view.magnet.next) {
var e = this._getCodeBlocks(a, c);
e.sort(function(a, b) {
return a.point - b.point;
});
e.unshift({point:-Number.MAX_VALUE, blocks:[]});
for (var f = 1;f < e.length;f++) {
var g = e[f], h = g, k = g.startBlock;
if (k) {
for (var l = g.endPoint, m = f;l > h.point && (h.blocks.push(k), m++, h = e[m], h);) {
}
delete g.startBlock;
}
delete f.startBlock;
g.endPoint = Number.MAX_VALUE;
e[f - 1].endPoint = g.point;
}
f.endPoint = Number.MAX_VALUE;
c[e - 1].endPoint = f.point;
this._magnetMap[c] = e;
}
this._magnetMap[b] = c;
}
}
};
Expand All @@ -23553,8 +23558,7 @@ Entry.Board.DRAG_RADIUS = 5;
f = this._getPreviousMagnets;
break;
case "string":
f = this._getFieldMagnets;
break;
;
case "boolean":
f = this._getFieldMagnets;
break;
Expand Down Expand Up @@ -24346,7 +24350,7 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3;
this.getCode().unregisterBlock(this);
f = this.getThread();
this._schema && this._schema.event && f.unregisterEvent(this, this._schema.event);
c && (b ? c.destroy(a, b) : g ? c.view && c.view.bindPrev(g) : (b = this.getThread().view.getParent(), b.constructor === Entry.FieldStatement ? (c.view && c.view.bindPrev(b), b.insertTopBlock(c)) : b.constructor === Entry.FieldStatement ? c.replace(b._valueBlock) : c.view._toGlobalCoordinate()));
c && (b ? c.destroy(a, b) : g ? c.view && c.view.bindPrev(g, !0) : (b = this.getThread().view.getParent(), b.constructor === Entry.FieldStatement ? (c.view && c.view.bindPrev(b), b.insertTopBlock(c)) : b.constructor === Entry.FieldStatement ? c.replace(b._valueBlock) : c.view._toGlobalCoordinate()));
!this.doNotSplice && f.spliceBlock ? f.spliceBlock(this) : delete this.doNotSplice;
this.view && this.view.destroy(a);
this._schemaChangeEvent && this._schemaChangeEvent.destroy();
Expand Down
Loading

0 comments on commit 4267556

Please sign in to comment.