Skip to content

Commit

Permalink
Released v0.2.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador committed Mar 13, 2014
1 parent 6b3e548 commit 9a53089
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
21 changes: 14 additions & 7 deletions angular-scroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
angular.module('duScroll', ['duScroll.scroller', 'duScroll.scrollPosition', 'duScroll.scrollspy', 'duScroll.requestAnimation', 'duScroll.smoothScroll']).value('duScrollDuration', 1000);
/**
* x is a value between 0 and 1, indicating where in the animation you are.
*/
var duScrollDefaultEasing = function (x) {
if(x < 0.5) {
return Math.pow(x*2, 2)/2;
}
return 1-Math.pow((1-x)*2, 2)/2;
};

angular.module('duScroll', ['duScroll.scroller', 'duScroll.scrollPosition', 'duScroll.scrollspy', 'duScroll.requestAnimation', 'duScroll.smoothScroll']).value('duScrollDuration', 1000).value('duScrollEasing', duScrollDefaultEasing);


angular.module('duScroll.requestAnimation', []).
Expand Down Expand Up @@ -61,11 +71,7 @@ factory('scrollPosition',

angular.module('duScroll.scroller', ['duScroll.requestAnimation']).
factory('scroller',
function($window, requestAnimation, scrollPosition) {

function easeout(x) {
return Math.pow(x, 0.7);
}
function($window, requestAnimation, scrollPosition, duScrollEasing) {

function scrollTo(x, y, duration){
if(!duration) {
Expand All @@ -86,7 +92,8 @@ factory('scroller',
var frames = Math.ceil(duration/60);
var animate = function() {
frame++;
var percent = (frame === frames ? 1 : easeout(frame/frames));
var percent = (frame === frames ? 1 : duScrollEasing(frame/frames));

$window.scrollTo(
start.x + Math.ceil(delta.x * percent),
start.y + Math.ceil(delta.y * percent)
Expand Down
2 changes: 1 addition & 1 deletion angular-scroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion angular-scroll.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-scroll",
"version": "0.2.7",
"version": "0.2.8",
"main": "angular-scroll.min.js",
"ignore": [
"**/.*",
Expand Down
Loading

0 comments on commit 9a53089

Please sign in to comment.