Skip to content

Commit

Permalink
Merge pull request surveyjs#3136 from surveyjs/feature/creator-1559-v…
Browse files Browse the repository at this point in the history
…2-restrict-drag-between-pages

work for the surveyjs/survey-creator#1559
  • Loading branch information
andrewtelnov authored Jul 27, 2021
2 parents ffee2e2 + 4f5be48 commit 5f019c2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/dragdrophelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class DragDropHelper extends Base {
public onBeforeDrop: EventBase<DragDropHelper> = new EventBase();
public onAfterDrop: EventBase<DragDropHelper> = new EventBase();

public static restrictDragQuestionBetweenPages: boolean = false;

public static edgeHeight: number = 30;
public static nestedPanelDepth: number = -1;
public static prevEvent: any = {
Expand Down Expand Up @@ -294,6 +296,15 @@ export class DragDropHelper extends Base {
return;
}

if (
DragDropHelper.restrictDragQuestionBetweenPages &&
dropTargetSurveyElement["page"] !==
(<any>this.draggedSurveyElement)["page"]
) {
this.banDropSurveyElement();
return;
}

if (dropTargetSurveyElement === this.ghostSurveyElement) {
return;
}
Expand Down Expand Up @@ -632,7 +643,9 @@ export class DragDropHelper extends Base {
this.onBeforeDrop.fire(this, null);
choices.splice(oldIndex, 1);
choices.splice(newIndex, 0, this.draggedSurveyElement);
this.onAfterDrop.fire(this, { draggedElement: this.itemValueParentQuestion });
this.onAfterDrop.fire(this, {
draggedElement: this.itemValueParentQuestion,
});
};

private clear = () => {
Expand Down

0 comments on commit 5f019c2

Please sign in to comment.