Events

Using the .on(), .once() and .off() methods you can subscribe and unsubscribe to events.

  • All of above mentioned methods are available on Taggd and Tag instances.
  • To subscribe to an event for all tags, subscribe to that event on the Taggd instance.

For example:

const image = document.getElementById('my-image');
const taggd = new Taggd(image);

// Prevent adding tags
taggd.on('taggd.tag.add', (tag) => {
  // Some events can be prevented by returning false (see tables below)
  return false;
});

// This tag isn’t added because of above event handler
taggd.add(new Taggd.Tag(..., ...));

Taggd Events

The table below lists all available tables for a Taggd instance.

All taggd.editor* event handlers receive the following arguments:

  1. Taggd instance
  2. [position] x/y/left/top

All taggd.tag* event handlers receive the following arguments:

  1. Taggd instance
  2. Tag instance
EventTriggeredIs preventable by returning false
taggd.destroybefore destroying a Taggd instanceyes
taggd.editor.enablebefore enable editor modeyes
taggd.editor.disablebefore disabling editor modeyes
taggd.editor.loadbefore load imageno
taggd.editor.loadedafter load imageno
taggd.editor.loaderrorafter error imageno
taggd.editor.addafter click image(no move trigger)no
taggd.editor.zoomafter zoom imageno
taggd.editor.movedownafter movedown imageno
taggd.editor.moveafter move imageno
taggd.editor.moveupafter moveup imageno
taggd.tag.addbefore adding a tag(move trigger)yes
taggd.tag.addedafter adding a tagno
taggd.tag.deletebefore deleting a tagyes
taggd.tag.deletedafter deleting a tagno
taggd.tag.showbefore showing a tagyes
taggd.tag.shownafter showing a tagno
taggd.tag.hidebefore hiding a tagyes
taggd.tag.hiddenafter hiding a tagno
taggd.tag.changebefore changing a tagyes
taggd.tag.changedafter changing a tagno
taggd.tag.clickafter click a tag(no move trigger)no
taggd.tag.editor.enablebefore enable editor modeyes
taggd.tag.editor.disablebefore disabling editor modeyes
taggd.tag.editor.movedownafter movedown a tagno
taggd.tag.editor.moveafter move a tagno
taggd.tag.editor.moveupafter moveup a tag(move trigger)no

Taggd.Tag Events

The table below lists all available tables for a Tag instance.

All taggd.tag.* event handlers receive the following argument:

  1. Tag instance
EventTriggeredIs preventable by returning false
taggd.tag.deletebefore deleting a tagyes
taggd.tag.deletedafter deleting a tagno
taggd.tag.showbefore showing a tagyes
taggd.tag.shownafter showing a tagno
taggd.tag.hidebefore hiding a tagyes
taggd.tag.hiddenafter hiding a tagno
taggd.tag.changebefore changing a tagyes
taggd.tag.changedafter changing a tagno
taggd.tag.clickafter click a tag(no move trigger)no
taggd.tag.editor.enablebefore enable editor modeyes
taggd.tag.editor.disablebefore disabling editor modeyes
taggd.tag.editor.movedownafter movedown a tagno
taggd.tag.editor.moveafter move a tagno
taggd.tag.editor.moveupafter moveup a tag(move trigger)no