h5p / h5p-drag-text

MIT License
7 stars 70 forks source link

xAPI event is triggered before the state has been updated when placing elements. #11

Open OliverColeman opened 7 years ago

OliverColeman commented 7 years ago

When an element is dragged into a drop zone an xAPI 'interacted' event is triggered before the state has been updated, which means the new/current state is not provided by a call to getXAPIData() in handlers listening for xAPI events. This behaviour also seems to be at odds with the way other content types work.

Moving the line this.trigger('addedToZone'); from the start of Draggable.prototype.addToZone to the end fixes this, ie:

  Draggable.prototype.addToZone = function (droppable) {
    if (this.insideDropzone !== null) {
      this.insideDropzone.removeDraggable();
    }
    this.toggleDroppedFeedback(true);
    this.insideDropzone = droppable;
    this.setShortFormat();
    this.trigger('addedToZone');
  };
tajakobsen commented 7 years ago

@OliverColeman We'll look into this. Thanks for reporting!