mmautomatizacion / mm.angular-fullpage.js

Angular directive for use the jQuery fullPage.js library on Angular.js v1.x
MIT License
17 stars 7 forks source link

Error if there is no active Section onLoad of Page 'Cannot read property 'top' of undefined' #5

Closed benjamindamm closed 7 years ago

benjamindamm commented 7 years ago

Hi,

Ive got another error when my page freshly reloads and I have no hashbanged URL. I think the function scrollToAnchor is searching for a string, that doesn't exist. I have made some screenshots for you. There you can see, that the functions checks with if(section) if the sections is existing. But problem is, there is not given the undefined as a condition to falsify, there is the string "undefined" contained, so the function continues.

By the way thanks for your Module, it saves me of a lot of work ;)

bildschirmfoto 2017-01-08 um 14 44 21 bildschirmfoto 2017-01-08 um 14 44 31

benjamindamm commented 7 years ago

I solved the problem with changing this 2 lines:

if(section && section != 'undefined'){ //if theres any #

//we need to scroll to the section and then to the slide if (destiny && destiny != 'undefined' && destiny !== lastScrolledDestiny && !section.hasClass(ACTIVE))

I don't know if you ever got this error. It occurs when you have a root url like my http://localhost:8888 without any paths to resolve for scrolling. I think this is a normal situation when your page gets loaded without the routing of the fullPage-Scrolling in url.

A second question: Is there any way to default load a section from the slide to the url? I got another problem. I load an url, also without any hashbanged urls inside like localhost:8888/blog, at this page my first section is directly on top of page and shows a slide. With a link I can change to slide number 2. So the url looks like this: localhost:8888/blog#!/overview/2, when pressing back button of the browser, it changes back to localhost:8888/blog and nothing is changing in my view, means I am remaining on the view of localhost:8888/blog#!/overview/2 I think its in cause of the application doesn't loaded localhost:8888/blog#!/overview/1 by default. If this can be set, it would solve my problem as discribed above.

Edit: Ive seen the original fullSlide.js has the same problem. A solution can be to auto redirect urls like localhost:8888/blog to localhost:8888/blog#!/overview but i think its a bad solution. Maybe we can improve the module to auto find the visible section and setting it to the url.

mmautomatizacion commented 7 years ago

Hi @benjamindamm, Are you using any routing engine like ng-router, ui-router...?

For the first problem, $location.path() value is "/" by default. I don't have any problem with the url (you can check It work correctly, without hash, in the example) in any situation. Maybe you can do a JSFiddle showing the problem.

The second problem seems to be related. You are not managing correctly the routing.

An advice: forget the routing. Angular-fullpage will route by you.