Skip to content

Commit

Permalink
feat(Authoring): When adding a new component, move immediately to it (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Apr 21, 2023
1 parent 0e55c24 commit 78a5603
Showing 1 changed file with 10 additions and 36 deletions.
46 changes: 10 additions & 36 deletions src/assets/wise5/authoringTool/node/nodeAuthoringComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,46 +494,20 @@ class NodeAuthoringController {
* @param newComponents an array of the new components we have just added
*/
highlightNewComponentsAndThenShowComponentAuthoring(newComponents) {
this.showComponentAuthoring();
this.turnOffInsertComponentMode();
this.showDefaultComponentsView();
this.clearComponentsToChecked();

// wait for the UI to update and then scroll to the first new component
this.$timeout(() => {
// allow the components time to show up in the UI
if (newComponents != null) {
if (newComponents != null && newComponents.length > 0) {
const componentElement = $('#' + newComponents[0].id);
$('#content').scrollTop(componentElement.offset().top - 200);
for (const newComponent of newComponents) {
if (newComponent != null) {
temporarilyHighlightElement(newComponent.id);
}
temporarilyHighlightElement(newComponent.id);
}
}

/*
* Wait a small amount of time before returning the UI back to the
* normal view. This allows the author to see the component number
* and type view a little longer so that they can see the change
* they just made before we switch back to the normal view.
*/
this.$timeout(() => {
this.showComponentAuthoring();
this.turnOffInsertComponentMode();
this.showDefaultComponentsView();
this.clearComponentsToChecked();

/*
* use a timeout to wait for the UI to update and then scroll
* to the first new component
*/
this.$timeout(() => {
if (newComponents != null && newComponents.length > 0) {
const componentElement = $('#' + newComponents[0].id);
if (componentElement != null) {
$('#content').animate(
{
scrollTop: componentElement.offset().top - 200
},
1000
);
}
}
}, 1000);
}, 1000);
});
}

Expand Down

0 comments on commit 78a5603

Please sign in to comment.