GeoloeG / iron-swipeable-pages

[Polymer 1.x] Element that enables switching between different pages by swiping gesture.
MIT License
49 stars 25 forks source link

Error with lazyLoading in Version 1.2.3 #33

Open dominikIncibit opened 8 years ago

dominikIncibit commented 8 years ago

In the newest version (1.2.3) when lazy loading components (by using lazy-pages) whith iron-swipeables-pages the followign error occurs in iron-swipeable-pages.html on line 314: Uncaught TypeError: Cannot read property 'offsetWidth' of undefined

MeTaNoV commented 8 years ago

Can you give me more detail about your setup? Since I don't have any lazy loading mechanism, how do you proceed? (My understanding is that currently, lazy-pages or iron-lazy-pages are replacement for iron-pages or neon-animated-pages

dominikIncibit commented 8 years ago

I tried reproducing the issue but it seems to work just fine in this basic setup: http://jsbin.com/wedafevetu/2/edit?html,output

So it must be related to something else in my code (I also updated a bunch of components at once, maybe its the fault of another one). Unfortunately I'm not in office until some day next week and I dont have the code available here. I will give you an update as soon as possible.

MeTaNoV commented 8 years ago

I see! No stress, I have other things to do meanwhile! :) Like set up a small working demo with carbon-route

dominikIncibit commented 8 years ago

How is your carbon-route demo going? :)

I just found out (at least partly) whats causing the issue. First of all it only happens when an Element containing iron-swipeable-pages takes really long to load. I am not sure why but this causes the code on line 201 to be executed:

_onDomChange: function(event) { if ( this.selectedItem && this.selectedItem.offsetWidth == 0 ) { this.selected = this.fallbackSelection; } },

However as the variable fallbackSelection isn't set (I can't even find it in the docu) its value is null and therefore selected is null which causes the exception. As a temporary workaround I just tried removing this code and everything works fine again. Nevertheless the if block should never even be entered in my opinion.

MeTaNoV commented 8 years ago

@fleckdalm is it still an issue I should look at?

dominikIncibit commented 8 years ago

Yes, please! I haven't tried your new versions as I haven't had any time but I had to fork your old version and remove this code in order to get it to work. It works perfectly fine for me this way :)