Sha256: 82ec3d1a2752acf8853fc4b89230dfde2e1c9c3288feb512d71851980811784f

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

pageflow.linkmapPage.Mask = function Mask(options) {
  var sprite = options.sprite;
  var spriteOffset = options.spriteOffset;
  var boundingBox = options.boundingBox;

  this.permaId = options.permaId;

  this.areaAttributes = function() {
    return {
      mask_perma_id: options.permaId,
      top: boundingBox.top / options.originalHeight * 100,
      left: boundingBox.left / options.originalWidth * 100,
      height: boundingBox.height / options.originalHeight * 100,
      width: boundingBox.width / options.originalWidth * 100
    };
  };

  this.contains = function(fractionX, fractionY) {
    var x = fractionX * options.originalWidth;
    var y = fractionY * options.originalHeight;

    var spriteX = x - boundingBox.left;
    var spriteY = y - boundingBox.top;

    if (spriteX < 0 || spriteX >= boundingBox.width ||
        spriteY < 0 || spriteY >= boundingBox.height) {
      return false;
    }

    return sprite.nonTransparentAt(spriteOffset + spriteX, spriteY);
  };

  this.draw = function(context, currentWidth) {
    var scale = currentWidth / options.originalWidth;
    sprite.draw(context, spriteOffset, boundingBox, scale);
  };
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pageflow-linkmap-page-1.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js
pageflow-linkmap-page-1.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js
pageflow-linkmap-page-1.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js
pageflow-linkmap-page-1.2.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js
pageflow-linkmap-page-1.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js
pageflow-linkmap-page-1.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js
pageflow-linkmap-page-1.0.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/mask.js