mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #620 from zoeesilcock/285-import-multiple-frames
Allow adding multiple frames with drag and drop
This commit is contained in:
commit
ac08ff8b82
|
@ -27,6 +27,8 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var files = event.dataTransfer.files;
|
var files = event.dataTransfer.files;
|
||||||
|
this.isMultipleFiles_ = (files.length > 1);
|
||||||
|
|
||||||
for (var i = 0; i < files.length ; i++) {
|
for (var i = 0; i < files.length ; i++) {
|
||||||
var file = files[i];
|
var file = files[i];
|
||||||
var isImage = file.type.indexOf('image') === 0;
|
var isImage = file.type.indexOf('image') === 0;
|
||||||
|
@ -62,12 +64,17 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.FileDropperService.prototype.processImageSource_ = function (imageSource) {
|
ns.FileDropperService.prototype.processImageSource_ = function (imageSource) {
|
||||||
this.importedImage_ = new Image();
|
var importedImage = new Image();
|
||||||
this.importedImage_.onload = this.onImageLoaded_.bind(this);
|
importedImage.onload = this.onImageLoaded_.bind(this, importedImage);
|
||||||
this.importedImage_.src = imageSource;
|
importedImage.src = imageSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.FileDropperService.prototype.onImageLoaded_ = function () {
|
ns.FileDropperService.prototype.onImageLoaded_ = function (importedImage) {
|
||||||
|
if (this.isMultipleFiles_) {
|
||||||
|
this.piskelController.addFrameAtCurrentIndex();
|
||||||
|
this.piskelController.selectNextFrame();
|
||||||
|
}
|
||||||
|
|
||||||
var currentFrame = this.piskelController.getCurrentFrame();
|
var currentFrame = this.piskelController.getCurrentFrame();
|
||||||
// Convert client coordinates to sprite coordinates
|
// Convert client coordinates to sprite coordinates
|
||||||
var spriteDropPosition = pskl.app.drawingController.getSpriteCoordinates(
|
var spriteDropPosition = pskl.app.drawingController.getSpriteCoordinates(
|
||||||
|
@ -78,7 +85,7 @@
|
||||||
var x = spriteDropPosition.x;
|
var x = spriteDropPosition.x;
|
||||||
var y = spriteDropPosition.y;
|
var y = spriteDropPosition.y;
|
||||||
|
|
||||||
pskl.utils.FrameUtils.addImageToFrame(currentFrame, this.importedImage_, x, y);
|
pskl.utils.FrameUtils.addImageToFrame(currentFrame, importedImage, x, y);
|
||||||
|
|
||||||
$.publish(Events.PISKEL_RESET);
|
$.publish(Events.PISKEL_RESET);
|
||||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user