From 46222e27263a74781af3ba13bf0f77490c0039f3 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Mon, 12 Jun 2017 12:11:40 +0200 Subject: [PATCH] Documentation ApertureHandler.js --- src/js/includes/ApertureHandler.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/js/includes/ApertureHandler.js b/src/js/includes/ApertureHandler.js index 54ac971..2095b87 100644 --- a/src/js/includes/ApertureHandler.js +++ b/src/js/includes/ApertureHandler.js @@ -1,5 +1,9 @@ 'use strict'; +/** + * ApertureHandler takes care of the bars around the image to show what area has been/will be cropped. + * @param {canvas} + */ function ApertureHandler(canvas) { var _items = {x: [], y: []}; @@ -27,6 +31,11 @@ function ApertureHandler(canvas) { } init(); + /** + * Applies configuration to the apertures apertures on the viewport + * @param {string} axis + * @param {viewport} + */ this.apply = function (axis, viewport) { this.getApertures(axis).forEach(function (o) { o.visible = false; @@ -56,10 +65,20 @@ function ApertureHandler(canvas) { canvas.renderAll(); }; + /** + * Gets the apertures on specified axis. If no axis is provided, both x and y are returned. + * @param {string} axis + * @returns {Array} + */ this.getApertures = function (axis) { return axis ? _items[axis] : [].concat(_items.x, _items.y); }; + /** + * Sets transparency of the apertures depending on the crop status + * @param {boolean} apply + * @returns {ApertureHandler} + */ this.setTransparent = function (apply) { this.getApertures().forEach(function (o) { o.opacity = apply ? 0.7 : 1;