Skip to content

Commit

Permalink
Scroll selected costume into view
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan committed Feb 9, 2015
1 parent 63a1c56 commit 7e8e34e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/pixie/pixie.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,21 @@
saveFile(defaultName + '.png', 'image/png', canvas.toDataURL().slice('data:image/png;base64,'.length), true);
}

function scrollIntoView(el, container) {
var bb = el.getBoundingClientRect();
var cbb = container.getBoundingClientRect();
if (bb.top < cbb.top) {
container.scrollTop += bb.top - cbb.top;
} else if (bb.bottom > cbb.bottom) {
container.scrollTop += bb.bottom - cbb.bottom;
}
if (bb.left < cbb.left) {
container.scrollLeft += bb.left - cbb.left;
} else if (bb.right > cbb.right) {
container.scrollLeft += bb.right - cbb.right;
}
}


function ScratchObj(name) {
this.name = name;
Expand Down Expand Up @@ -4419,6 +4434,7 @@
}
if (this.selectedIcon = icon) {
icon.select();
scrollIntoView(icon.el, this.elList);
this.imageEditor.costume = icon.costume;
}
};
Expand Down

0 comments on commit 7e8e34e

Please sign in to comment.