all files / models/stage/ stage.js

63.83% Statements 30/47
38.46% Branches 5/13
64.29% Functions 9/14
63.83% Lines 30/47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101  19× 19× 19× 19×   30×   16×                                                     18×                               24×                                                      
"use strict";
var immutable_class_1 = require('immutable-class');
var check;
var Stage = (function () {
    function Stage(parameters) {
        this.x = parameters.x;
        this.y = parameters.y;
        this.width = parameters.width;
        this.height = parameters.height;
    }
    Stage.isStage = function (candidate) {
        return immutable_class_1.isInstanceOf(candidate, Stage);
    };
    Stage.fromJS = function (parameters) {
        return new Stage({
            x: parameters.x,
            y: parameters.y,
            width: parameters.width,
            height: parameters.height
        });
    };
    Stage.fromClientRect = function (rect) {
        return new Stage({
            x: rect.left,
            y: rect.top,
            width: rect.width,
            height: rect.height
        });
    };
    Stage.fromSize = function (width, height) {
        return new Stage({
            x: 0,
            y: 0,
            width: width,
            height: height
        });
    };
    Stage.prototype.valueOf = function () {
        return {
            x: this.x,
            y: this.y,
            width: this.width,
            height: this.height
        };
    };
    Stage.prototype.toJS = function () {
        return {
            x: this.x,
            y: this.y,
            width: this.width,
            height: this.height
        };
    };
    Stage.prototype.toJSON = function () {
        return this.toJS();
    };
    Stage.prototype.sizeOnlyValue = function () {
        return {
            x: 0,
            y: 0,
            width: this.width,
            height: this.height
        };
    };
    Stage.prototype.toString = function () {
        return "[stage: " + this.width + "x" + this.height + "}]";
    };
    Stage.prototype.equals = function (other) {
        return Stage.isStage(other) &&
            this.x === other.x &&
            this.y === other.y &&
            this.width === other.width &&
            this.height === other.height;
    };
    Stage.prototype.getTransform = function () {
        return "translate(" + this.x + "," + this.y + ")";
    };
    Stage.prototype.within = function (param) {
        var value = this.sizeOnlyValue();
        var left = param.left, right = param.right, top = param.top, bottom = param.bottom;
        if (left) {
            value.x = left;
            value.width -= left;
        }
        if (right) {
            value.width -= right;
        }
        if (top) {
            value.y = top;
            value.height -= top;
        }
        if (bottom) {
            value.height -= bottom;
        }
        return new Stage(value);
    };
    return Stage;
}());
exports.Stage = Stage;
check = Stage;