ngSmoothScroll
ngSmoothScroll copied to clipboard
smoothScroll doesn't work on SVG Elements
Trying to use this awesome directive with SVG elements does not work. I seems the end position could not be calculated for SVG Elements.
I made a workaround by using the offset option and calculating the SVG-Element position. Would be aweseome if you integrate SVG support.
Position for svg element can be calculated like this:
//is SVG Element?
if( element instanceof SVGElement) {
return calcSVGPosition(element)
}
else calcNormalEndPosition(...);
function calcSVGPosition(element){
var elementsRelativYPosition = element.getScreenCTM().f;
var currentPos = $window.pageYOffset;
var elementsAbsolutYPosition = currentPos + elementsRelativYPosition;
return elementsAbsolutYPosition;
}