P5-1922 fix jslint warnings
This commit is contained in:
+47
-46
@@ -1,4 +1,5 @@
|
||||
'use strict';
|
||||
/* globals $, fabric */
|
||||
|
||||
var FrameHandler = require('./FrameHandler');
|
||||
var GoreHandler = require('./GoreHandler');
|
||||
@@ -12,52 +13,6 @@ function Viewport(canvas) {
|
||||
var _rect;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* Applies viewport to page
|
||||
*/
|
||||
function apply() {
|
||||
var cropData = canvas.getImageData().getCropData();
|
||||
canvas.remove(_rect);
|
||||
|
||||
_rect = new fabric.Rect({
|
||||
evented: false,
|
||||
fill: 'transparent',
|
||||
width: _data.width,
|
||||
height: _data.height,
|
||||
stroke: '#fff',
|
||||
strokeWidth: canvas.__type === 'canvas' ? 0 : _borderWidth
|
||||
});
|
||||
|
||||
_rect.width += _borderWidth;
|
||||
_rect.height += _borderWidth;
|
||||
_rect.addTo(canvas).center().setCoords();
|
||||
|
||||
if (cropData) {
|
||||
// Calculate the new position after screenresize and when the
|
||||
// image already has been cropped to a certain position.
|
||||
var left = _rect.left + _rect.strokeWidth - (canvas.getImage().width * canvas.getImage().scaleX * cropData.x);
|
||||
var top = _rect.top + _rect.strokeWidth - (canvas.getImage().height * canvas.getImage().scaleY * cropData.y);
|
||||
|
||||
canvas.getImage().set({ left: left, top: top }).setCoords();
|
||||
} else {
|
||||
canvas.getImage().center().setCoords();
|
||||
}
|
||||
|
||||
canvas.getImage().drag.enable(calcMinMaxBoundsForRect(_rect.getInsideBoundingRect(), canvas.getImage()));
|
||||
canvas.getApertures().apply(_data.axis, _rect.getBoundingRect());
|
||||
|
||||
if (canvas.__type !== 'canvas') {
|
||||
drawBeams();
|
||||
} else {
|
||||
self.setFrame(self.getFrameHandler().getFrameType());
|
||||
}
|
||||
|
||||
canvas.getDragbars().apply();
|
||||
// Apertures sometimes overlaps the viewports bounding rect.
|
||||
// Solve this by bringing it to the front after apertures are applied.
|
||||
_rect.bringToFront();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the diagonal lines from viewport to edge of the canvas
|
||||
*/
|
||||
@@ -108,6 +63,52 @@ function Viewport(canvas) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies viewport to page
|
||||
*/
|
||||
function apply() {
|
||||
var cropData = canvas.getImageData().getCropData();
|
||||
canvas.remove(_rect);
|
||||
|
||||
_rect = new fabric.Rect({
|
||||
evented: false,
|
||||
fill: 'transparent',
|
||||
width: _data.width,
|
||||
height: _data.height,
|
||||
stroke: '#fff',
|
||||
strokeWidth: canvas.__type === 'canvas' ? 0 : _borderWidth
|
||||
});
|
||||
|
||||
_rect.width += _borderWidth;
|
||||
_rect.height += _borderWidth;
|
||||
_rect.addTo(canvas).center().setCoords();
|
||||
|
||||
if (cropData) {
|
||||
// Calculate the new position after screenresize and when the
|
||||
// image already has been cropped to a certain position.
|
||||
var left = _rect.left + _rect.strokeWidth - (canvas.getImage().width * canvas.getImage().scaleX * cropData.x);
|
||||
var top = _rect.top + _rect.strokeWidth - (canvas.getImage().height * canvas.getImage().scaleY * cropData.y);
|
||||
|
||||
canvas.getImage().set({ left: left, top: top }).setCoords();
|
||||
} else {
|
||||
canvas.getImage().center().setCoords();
|
||||
}
|
||||
|
||||
canvas.getImage().drag.enable(calcMinMaxBoundsForRect(_rect.getInsideBoundingRect(), canvas.getImage()));
|
||||
canvas.getApertures().apply(_data.axis, _rect.getBoundingRect());
|
||||
|
||||
if (canvas.__type !== 'canvas') {
|
||||
drawBeams();
|
||||
} else {
|
||||
self.setFrame(self.getFrameHandler().getFrameType());
|
||||
}
|
||||
|
||||
canvas.getDragbars().apply();
|
||||
// Apertures sometimes overlaps the viewports bounding rect.
|
||||
// Solve this by bringing it to the front after apertures are applied.
|
||||
_rect.bringToFront();
|
||||
}
|
||||
|
||||
this.canvas = canvas;
|
||||
|
||||
this.getBounds = function () {
|
||||
|
||||
Reference in New Issue
Block a user