From 5ba978311ed6fada5d15c8fcf4024f1c55a2b234 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Fri, 28 Feb 2020 21:47:22 +0000 Subject: [PATCH] Fix "Cannot read property 'anchor' of undefined" --- src/ol/View.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ol/View.js b/src/ol/View.js index 27ab568daa..8a8234c354 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -609,10 +609,14 @@ class View extends BaseObject { if (series[0].callback) { animationCallback(series[0].callback, false); } - anchor = anchor || - series.filter(function(animation) { + if (!anchor) { + const animations = series.filter(function(animation) { return !animation.complete; - })[0].anchor; + }); + if (animations.length > 0) { + anchor = animations[0].anchor; + } + } } this.animations_.length = 0; this.cancelAnchor_ = anchor;