Skip to content

Conversation

boujeepossum
Copy link

I have a backbone application, where map is rendered once and then stored globally. And sometimes when users open another page before animation is complete, it gives me a bunch of errors.

Uncaught TypeError: Cannot read property '1' of null leaflet.js:8210
L.PosAnimation.L.Class.extend._getPos leaflet.js:8210
L.PosAnimation.L.Class.extend._onStep leaflet.js:8193
(anonymous function)

on that line.

_getPos: function () {
        var left, top, matches,
            el = this._el,
            style = window.getComputedStyle(el);

        if (L.Browser.any3d) {
            matches = style[L.DomUtil.TRANSFORM].match(this._transformRe);
            left = parseFloat(matches[1]);
--------------   Uncaught TypeError: Cannot read property '1' of null
            top  = parseFloat(matches[2]);
        } else {
            left = parseFloat(style.left);
            top  = parseFloat(style.top);
        }

        return new L.Point(left, top, true);
    },

@mourner
Copy link
Member

mourner commented Jul 10, 2013

It was fixed recently but in a slightly different way. https://github.com/Leaflet/Leaflet/blob/master/src/dom/PosAnimation.js#L61-L62
Thanks for the pull though!

@mourner mourner closed this Jul 10, 2013
@boujeepossum
Copy link
Author

but will it stop transition in this case? because what i had is infinite setInterval which only cleared when i go back to the map page

@mourner
Copy link
Member

mourner commented Jul 11, 2013

@rutkovsky if it's the case, then you're right! I didn't want to merge this fix because step listener is performance-sensitive since it happens often el.contains may be slow... Perhaps lets make a similar fix but with a different condition — checking for existance of matches when parsing transform.

@boujeepossum
Copy link
Author

@mourner will that work? #1856

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

Successfully merging this pull request may close these issues.

2 participants