All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.assets.rjzjh.echarts.src.component.helper.interactionMutex.js Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
define(function (require) {

    var ATTR = '\0_ec_interaction_mutex';

    var interactionMutex = {

        take: function (zr, resourceKey, userKey, onTakeAway) {
            var store = getStore(zr);
            var record = store[resourceKey];

            record && record.onTakeAway && record.onTakeAway();

            store[resourceKey] = {
                userKey: userKey,
                onTakeAway: onTakeAway
            };
        },

        release: function (zr, resourceKey, userKey) {
            var store = getStore(zr);
            var record = store[resourceKey];

            if (record.userKey === userKey) {
                store[resourceKey] = null;
            }
        },

        isTaken: function (zr, resourceKey) {
            return !!getStore(zr)[resourceKey];
        }
    };

    function getStore(zr) {
        return zr[ATTR] || (zr[ATTR] = {});
    }

    return interactionMutex;
});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy