diff --git a/src/js/controller/dialogs/importwizard/steps/AbstractImportStep.js b/src/js/controller/dialogs/importwizard/steps/AbstractImportStep.js index 5a6dc86d..f8450929 100644 --- a/src/js/controller/dialogs/importwizard/steps/AbstractImportStep.js +++ b/src/js/controller/dialogs/importwizard/steps/AbstractImportStep.js @@ -23,6 +23,10 @@ }; ns.AbstractImportStep.prototype.destroy = function () { + if (this.framePickerWidget) { + this.framePickerWidget.destroy(); + } + pskl.utils.Event.removeAllEventListeners(this); }; diff --git a/src/js/controller/dialogs/importwizard/steps/InsertLocation.js b/src/js/controller/dialogs/importwizard/steps/InsertLocation.js index 9528486c..e0833e93 100644 --- a/src/js/controller/dialogs/importwizard/steps/InsertLocation.js +++ b/src/js/controller/dialogs/importwizard/steps/InsertLocation.js @@ -35,7 +35,10 @@ }; ns.InsertLocation.prototype.onShow = function () { + // Initialize the frame picker on show, to be able to calculate correctly the + // container's offsetWidth and offsetHeight. this.currentPiskelFramePickerWidget.init(); + var currentFrameIndex = this.piskelController.getCurrentFrameIndex(); this.currentPiskelFramePickerWidget.setFrameIndex(currentFrameIndex + 1); this.currentPiskelFramePickerWidget.setFirstFrameIndex(0); diff --git a/src/js/controller/dialogs/importwizard/steps/SelectMode.js b/src/js/controller/dialogs/importwizard/steps/SelectMode.js index 937f09cb..2b473941 100644 --- a/src/js/controller/dialogs/importwizard/steps/SelectMode.js +++ b/src/js/controller/dialogs/importwizard/steps/SelectMode.js @@ -28,9 +28,6 @@ }; ns.SelectMode.prototype.destroy = function () { - if (this.framePickerWidget) { - this.framePickerWidget.destroy(); - } this.superclass.destroy.call(this); }; diff --git a/src/js/widgets/FramePicker.js b/src/js/widgets/FramePicker.js index 798af80f..48f8e6ea 100644 --- a/src/js/widgets/FramePicker.js +++ b/src/js/widgets/FramePicker.js @@ -59,7 +59,10 @@ }; ns.FramePicker.prototype.destroy = function () { - this.container.removeChild(this.wrapper); + if (this.wrapper.parentNode) { + this.wrapper.parentNode.removeChild(this.wrapper); + } + pskl.utils.Event.removeAllEventListeners(this); };