"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var vdom_1 = require("@dojo/framework/core/vdom");
var global_1 = require("@dojo/framework/shim/global");
var factory = vdom_1.create({ destroy: vdom_1.destroy });
var bodyStyle = global_1.default.document.body.style;
exports.bodyScroll = factory(function bodyScroll(_a) {
    var destroy = _a.middleware.destroy;
    var disabled = false;
    var previousOverflow = undefined;
    var enableScroll = function () {
        if (!disabled) {
            return;
        }
        if (previousOverflow) {
            bodyStyle.setProperty('overflow', previousOverflow);
        }
        else {
            bodyStyle.removeProperty('overflow');
        }
        disabled = false;
        previousOverflow = undefined;
    };
    var disableScroll = function () {
        if (disabled) {
            return;
        }
        disabled = true;
        previousOverflow = bodyStyle.getPropertyValue('overflow');
        bodyStyle.setProperty('overflow', 'hidden');
    };
    destroy(function () {
        disabled && enableScroll();
    });
    return function (enable) {
        enable ? enableScroll() : disableScroll();
    };
});
exports.default = exports.bodyScroll;

/*# sourceMappingURL=bodyScroll.js.map*/