Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using .setActiveArea multiple times #4

Closed
dagjomar opened this issue Aug 14, 2014 · 2 comments
Closed

using .setActiveArea multiple times #4

dagjomar opened this issue Aug 14, 2014 · 2 comments

Comments

@dagjomar
Copy link
Contributor

after map.setActiveArea({with some css})
the plugin creates a div with the given properties.

If I want to change the active area size later, I wish to just use the same function again, with new css:
map.setActiveArea({new css properties});

however, this creates a new div again, if I am not mistaken. Because:

    setActiveArea: function (css) {
            var container = this.getContainer();
            this._viewport = L.DomUtil.create('div', '');
            container.insertBefore(this._viewport, container.firstChild);

        if (typeof css === 'string') {
            this._viewport.className = css;
        } else {
            L.extend(this._viewport.style, css);
        }
        return this;
    }

If I put in a simple check for already existing viewport, I can avoid this and get the functionality I want:

    setActiveArea: function (css) {
        if( !this._viewport ){
            //Make viewport if not already made
            var container = this.getContainer();
            this._viewport = L.DomUtil.create('div', '');
            container.insertBefore(this._viewport, container.firstChild);
        }

        if (typeof css === 'string') {
            this._viewport.className = css;
        } else {
            L.extend(this._viewport.style, css);
        }
        return this;
    }

Valid feature for merging?

@mcellier
Copy link
Contributor

Yes. Will you make a PR ?

@dagjomar
Copy link
Contributor Author

Yes, working on it and adding test cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants