ngSmoothScroll icon indicating copy to clipboard operation
ngSmoothScroll copied to clipboard

not compatible with ui-sref

Open viz opened this issue 10 years ago • 8 comments

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?

viz avatar Nov 25 '14 01:11 viz

I'm facing the same issue.

mujuni88 avatar Feb 16 '15 23:02 mujuni88

So do I

KimSchneider avatar May 08 '15 13:05 KimSchneider

+1 same here

celsomtrindade avatar Oct 22 '15 22:10 celsomtrindade

+1

vrockai avatar Nov 01 '15 13:11 vrockai

+1

ghost avatar Nov 02 '15 23:11 ghost

+1 Same with my current project

helisz avatar Apr 29 '16 03:04 helisz

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

TheSharpieOne avatar Jun 09 '16 14:06 TheSharpieOne

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

keshavr7 avatar Jun 27 '16 15:06 keshavr7