JSFiddle - React, Tailwind, and code Playground

by gschutz

JavaScript

var Screen = (function(){
    var Screen = function() {
        var x = 0, y = 0;
        var _relative = 1;
        
        this.x = function(_x) {
            x = _x || x;
            var t = _x ? this : x / _relative;
            this.without();
            return t;
        }
        
        this.y = function(_y) {
            y = _y || y;
            var t = _y ? this : y / _relative;
            this.without();
            return t;
        }
        
        this.position = function(_x, _y) {
            y = _y || y;
            x = _x || x;
            var t = ( _y || _x ) 
            ? this 
            : {
                x: x / _relative, 
                y: y / _relative
            };
            this.without();
            return t;
        }
        
        this.without = function(z) {
            _relative = z || 1;
            return this;
        }
    }
    
    return new Screen();
});

var a = new Screen();
var b = Screen();
var zoom = 1.8;

console.log(a.position(21,13));
console.log(a.position());
console.log(a.without(zoom).position());