From ce6d7bd55cd43832764778b27b4c32fe24fd34ef Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Sat, 29 Feb 2020 10:12:48 +0000 Subject: [PATCH] Fix "Cannot read property 'anchor' of undefined" replace unnecessary filter with for loop and break --- src/ol/View.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ol/View.js b/src/ol/View.js index 8a8234c354..9b5211fdf1 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -610,11 +610,12 @@ class View extends BaseObject { animationCallback(series[0].callback, false); } if (!anchor) { - const animations = series.filter(function(animation) { - return !animation.complete; - }); - if (animations.length > 0) { - anchor = animations[0].anchor; + for (let j = 0, jj = series.length; j < jj; ++j) { + const animation = series[j]; + if (!animation.complete) { + anchor = animation.anchor; + break; + } } } }