Skip to content

Commit

Permalink
Replace el.scrollTo usage with doScrollTo (#167)
Browse files Browse the repository at this point in the history
* dont use el.scrollTo, use doScrollTo 

I happen to have jquery.scrollTo installed which has a different api than your `scrollTo` method. It overwrites your method with its own. 

Your method takes params of (left, top,  ... ) while their method is (top, ....) which is really bad. 

without this fix, I am forced to remove scrollTo and rewrite some legacy code to make use of your scrollTo method, which is ok, but not ideal.

Also the bug this caused was hard to track down.

* $window isnt an jqlite element :P
  • Loading branch information
mkoryak authored and oblador committed May 4, 2017
1 parent 3f4f9ac commit 54ed345
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ angular.module('duScroll.scrollHelpers', ['duScroll.requestAnimation'])
}
var el = unwrap(this);
if(isDocument(el)) {
return $window.scrollTo(left, top);
return angular.element($window).duScrollTo(left, top);
}
el.scrollLeft = left;
el.scrollTop = top;
Expand Down Expand Up @@ -79,7 +79,7 @@ angular.module('duScroll.scrollHelpers', ['duScroll.requestAnimation'])
progress = timestamp - startTime;
var percent = (progress >= duration ? 1 : easing(progress/duration));

el.scrollTo(
el.duScrollTo(
startLeft + Math.ceil(deltaLeft * percent),
startTop + Math.ceil(deltaTop * percent)
);
Expand Down

0 comments on commit 54ed345

Please sign in to comment.