Esri / storymap-shortlist

The Shortlist story map application template by Esri
http://storymaps.arcgis.com/en/app-list/shortlist/
Apache License 2.0
43 stars 61 forks source link

Map Recenters on Wrong Place after Selection #73

Open nheick opened 7 years ago

nheick commented 7 years ago

When selecting a new place on the map after a place has been selected from the map, the tile panel, or the detail panel, the map will inconsistently recenter on the previous selection, the point for the next slide after the previous selection, and sometimes the current selection. This only occurs when zoomed in to the point where not all the features are displayed. I've traced the issue back to the following function in DetailPanel.js:

this.showDetails = function (selected) {
    ...
    prepSwiperDisplay();

This appears to cause the detail panel to advance to the next slide and return to the current slide. With the selection on top of that, the active slide changes three times. Each slide change then creates multiple events including the onSlideChangeEnd event. These events trigger the onSlideChangeEnd event handler assigned in the buildSlides function:

newSwiper.on('onSlideChangeEnd', function (swiper) {
    ...
    if (_mainView.selected && !app.map.extent.contains(_mainView.selected.geometry) && ! app.data.getWebAppData().getGeneralOptions().filterByExtent || app.isInBuilder) {
        app.map.centerAt(_mainView.selected.geometry);
        }
    }
    ...

Therefore, the map pans once for each of the three features that aren't in the current extent. The current extent also changes after each pan. On top of that, these pans are not necessarily in the order the active slide changes. This means that the map might pan multiple times very quickly, sometimes showing other areas altogether, before stopping at one of these three locations.

Removing the call to prepSwiperDisplay() eliminates the issue along with the detail panel hiding and reappearing in a flash. It does cause a new issue, which is that when you click on a point on the map for the first time, the detail panel starts on your first slide and then takes a noticeable while to switch to the selected slide. Also, setting a timeout on the map recentering fixes the problem, but it doesn't seem to be the best solution.

I am using IE 11 and the Shortlist 2.1.0 app.

Thanks, Nathan