Skip to content

Commit

Permalink
Released 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador committed Nov 21, 2013
1 parent 89f4bc7 commit 905ef7c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
angular-scroll
==============

Only dependent on AngularJS (no jQuery). 2.5K minified or 0.5K gzipped.
Only dependent on AngularJS (no jQuery). 2.6K minified or 0.6K gzipped.

Example
-------
Expand Down
31 changes: 22 additions & 9 deletions angular-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ factory('scrollPosition',
}
};

var getScrollY = function() {
return $window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
};

var getScrollX = function() {
return $window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
};

angular.element($document).on('scroll', function(){
lastScrollY = $window.scrollY || document.documentElement.scrollTop;
lastScrollY = getScrollY();

if(lastScrollY !== currentScrollY){
requestAnimation(executeCallbacks);
Expand All @@ -38,13 +46,17 @@ factory('scrollPosition',
return {
observe : function(cb){
observers.push(cb);
}
},
x: getScrollX,
y: getScrollY
};
});
}
);


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

function easeout(x) {
return Math.pow(x, 0.7);
Expand All @@ -56,8 +68,8 @@ factory('scroller',
return;
}
var start = {
y: $window.scrollY,
x: $window.scrollX
y: scrollPosition.y(),
x: scrollPosition.x()
};
var delta = {
y: Math.round(y - start.y),
Expand All @@ -82,7 +94,7 @@ factory('scroller',
}

function scrollDelta(x, y, duration){
scrollTo($window.scrollX + (x || 0), $window.scrollY + (y || 0), duration);
scrollTo(scrollPosition.x() + (x || 0), scrollPosition.y() + (y || 0), duration);
}

return {
Expand All @@ -92,6 +104,7 @@ factory('scroller',
}
);


angular.module('duScroll.smoothScroll', ['duScroll.scroller']).
directive('duSmoothScroll', function(scroller){

Expand All @@ -101,21 +114,21 @@ directive('duSmoothScroll', function(scroller){
element.on('click', function(e){
if(!$attr.href || $attr.href.indexOf('#') === -1) return;
var elem = document.getElementById($attr.href.replace(/.*(?=#[^\s]+$)/, '').substring(1));
if(!elem) return;
if(!elem || !elem.getBoundingClientRect) return;

if (e.stopPropagation) e.stopPropagation();
if (e.preventDefault) e.preventDefault();

var offset = -($attr.offset ? parseInt($attr.offset, 10) : 0);
var pos = elem.getBoundingClientRect();

var delta = pos.top;
scroller.scrollDelta(0, pos.top + (isNaN(offset) ? 0 : offset), 1000);
});
}
};
});


angular.module('duScroll.scrollspy', ['duScroll.scrollPosition']).
directive('duScrollspy', function(scrollPosition) {
var spies = [];
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.

4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-scroll",
"version": "0.2.1",
"version": "0.2.2",
"main": "angular-scroll.min.js",
"ignore": [
"**/.*",
Expand All @@ -12,6 +12,6 @@
"src"
],
"dependencies": {
"angular": "~1.2.0-rc.2"
"angular": "~1.2.1"
}
}
3 changes: 2 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html ng-app="myApp">
<head>
<meta charset="UTF-8" />
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<title>Angular Scrollspy Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
Expand Down Expand Up @@ -114,7 +115,7 @@ <h2>Section 4</h2>
</footer>
</div>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script src="http://durated.github.io/angular-scroll/angular-scroll.min.js"></script>
<script>
angular.module('myApp', ['duScroll']).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-scroll",
"version": "0.2.0",
"version": "0.2.2",
"description": "Scrollspy, animated scrollTo and scroll events",
"keywords": ["angular", "smooth-scroll", "scrollspy", "scrollTo", "scrolling"],
"main": "angular-scroll.min.js",
Expand Down

0 comments on commit 905ef7c

Please sign in to comment.