Skip to content

Commit 6c85ef7

Browse files
committed
Merge pull request code-dot-org#590 from code-dot-org/droplet_scroll_private_fix
private fix for droplet scrolling
2 parents 5dc200b + 6981a08 commit 6c85ef7

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

blockly/lib/droplet/droplet-full.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10236,7 +10236,11 @@ if(i=this.variable instanceof Z){if(this.variable.isArray()||this.variable.isObj
1023610236
}
1023710237
};
1023810238
hook('mousedown', 10, function() {
10239-
return this.dropletElement.focus();
10239+
var x, y;
10240+
x = document.body.scrollLeft;
10241+
y = document.body.scrollTop;
10242+
this.dropletElement.focus();
10243+
return window.scrollTo(x, y);
1024010244
});
1024110245
hook('populate', 0, function() {
1024210246
this.undoStack = [];
@@ -10568,7 +10572,6 @@ if(i=this.variable instanceof Z){if(this.variable.isArray()||this.variable.isObj
1056810572
if (this.draggingBlock != null) {
1056910573
position = new this.draw.Point(point.x + this.draggingOffset.x, point.y + this.draggingOffset.y);
1057010574
rect = this.wrapperElement.getBoundingClientRect();
10571-
console.log(position.x - this.wrapperElement.getBoundingClientRect().left, position.y - this.wrapperElement.getBoundingClientRect().top);
1057210575
this.dragCanvas.style.top = "" + (position.y - rect.top) + "px";
1057310576
this.dragCanvas.style.left = "" + (position.x - rect.left) + "px";
1057410577
mainPoint = this.trackerPointToMain(position);
@@ -13247,10 +13250,13 @@ if(i=this.variable instanceof Z){if(this.variable.isArray()||this.variable.isObj
1324713250
})(this));
1324813251
});
1324913252
hook('keydown', 0, function(event, state) {
13250-
var _ref1;
13253+
var x, y, _ref1;
1325113254
if (_ref1 = event.which, __indexOf.call(command_modifiers, _ref1) >= 0) {
1325213255
if (this.textFocus == null) {
13256+
x = document.body.scrollLeft;
13257+
y = document.body.scrollTop;
1325313258
this.copyPasteInput.focus();
13259+
window.scrollTo(x, y);
1325413260
if (this.lassoSegment != null) {
1325513261
this.copyPasteInput.value = this.lassoSegment.stringify(this.mode.empty);
1325613262
}

blockly/lib/droplet/droplet-full.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blockly/lib/droplet/droplet-full.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blockly/lib/droplet/droplet.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8573,7 +8573,11 @@ if(i=this.variable instanceof Z){if(this.variable.isArray()||this.variable.isObj
85738573
}
85748574
};
85758575
hook('mousedown', 10, function() {
8576-
return this.dropletElement.focus();
8576+
var x, y;
8577+
x = document.body.scrollLeft;
8578+
y = document.body.scrollTop;
8579+
this.dropletElement.focus();
8580+
return window.scrollTo(x, y);
85778581
});
85788582
hook('populate', 0, function() {
85798583
this.undoStack = [];
@@ -8905,7 +8909,6 @@ if(i=this.variable instanceof Z){if(this.variable.isArray()||this.variable.isObj
89058909
if (this.draggingBlock != null) {
89068910
position = new this.draw.Point(point.x + this.draggingOffset.x, point.y + this.draggingOffset.y);
89078911
rect = this.wrapperElement.getBoundingClientRect();
8908-
console.log(position.x - this.wrapperElement.getBoundingClientRect().left, position.y - this.wrapperElement.getBoundingClientRect().top);
89098912
this.dragCanvas.style.top = "" + (position.y - rect.top) + "px";
89108913
this.dragCanvas.style.left = "" + (position.x - rect.left) + "px";
89118914
mainPoint = this.trackerPointToMain(position);
@@ -11584,10 +11587,13 @@ if(i=this.variable instanceof Z){if(this.variable.isArray()||this.variable.isObj
1158411587
})(this));
1158511588
});
1158611589
hook('keydown', 0, function(event, state) {
11587-
var _ref1;
11590+
var x, y, _ref1;
1158811591
if (_ref1 = event.which, __indexOf.call(command_modifiers, _ref1) >= 0) {
1158911592
if (this.textFocus == null) {
11593+
x = document.body.scrollLeft;
11594+
y = document.body.scrollTop;
1159011595
this.copyPasteInput.focus();
11596+
window.scrollTo(x, y);
1159111597
if (this.lassoSegment != null) {
1159211598
this.copyPasteInput.value = this.lassoSegment.stringify(this.mode.empty);
1159311599
}

0 commit comments

Comments
 (0)