d-oliveros / ngSmoothScroll

AngularJS directives for animating smooth scrolling to elements.
276 stars 112 forks source link

not compatible with ui-sref #14

Open viz opened 9 years ago

viz commented 9 years ago

I've added a scroll-to attribute to an existing tag with a ui-sref attribute and the scrolling seems to negate the state change.

So the effect is that the scroll works ok, but the ui-router state doesn't change. For now, I'm using a callback to explicitly change the state, but I'd much rather have it work as expected:

Nav link

smoothly scrolls to the target point and changes state.

Any thoughts?

mujuni88 commented 9 years ago

I'm facing the same issue.

KimSchneider commented 9 years ago

So do I

celsomtrindade commented 8 years ago

+1 same here

vrockai commented 8 years ago

+1

ghost commented 8 years ago

+1

helisz commented 8 years ago

+1 Same with my current project

TheSharpieOne commented 8 years ago

This and #68 are related, it is the return false in the click handler which stops the event from propagating to other handlers. This is related to jQuery and jQuery's events and how angular uses jQuery (instead of jqLite) when it is present when angular loads. Essentially, return false from within a jQuery event handler is effectively the same as calling both event.preventDefault and event.stopPropagation on the passed jQuery.Event object. This causes it to not trigger other handlers.

Workaround: Load angular before jQuery. Angular will use jqLite Note: If some of your angular logic (or other third-party angular logic) depend on angular using jQuery instead of the default jqLite, it will break.

Fix: Remove the return false, it is not exactly needed since event.preventDefault is called. I am not 100% sure if jqLite's event will always have preventDefault, but it is currently assumed to always be there anyways (the current code does not check if it exists before it calls it), something like event.preventDefault ? event.preventDefault() : event.returnValue = false; works well and will work in IE too.

More infotmation about angular and jqLite vs jQuery: https://docs.angularjs.org/api/ng/function/angular.element More information about jQuery events vs regular events: http://stackoverflow.com/a/1357151/1873485

keshavr7 commented 8 years ago

I haven't included jQuery. Still facing this issue.