summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/image_diff/image_badge.js
blob: 51a8cda98d73c5cb95428f573ecc4694d5651a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import imageDiffHelper from './helpers/index';

const defaultMeta = {
  x: 0,
  y: 0,
  width: 0,
  height: 0,
};

export default class ImageBadge {
  constructor(options) {
    const { noteId, discussionId } = options;

    this.actual = options.actual || defaultMeta;
    this.browser = options.browser || defaultMeta;
    this.noteId = noteId;
    this.discussionId = discussionId;

    if (options.imageEl && !options.browser) {
      this.browser = imageDiffHelper.resizeCoordinatesToImageElement(options.imageEl, this.actual);
    }
  }
}