Skip to content

Commit

Permalink
Better IE8 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador committed Apr 23, 2014
1 parent 9deeb22 commit 46f2f4e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion example/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
top: 0;
left: 0;
right: 0;
background: #fff;
background: rgba(255, 255, 255, 0.8);
}
nav li, nav ul {
Expand Down Expand Up @@ -127,7 +128,7 @@ <h2>Section 4</h2>
</div>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<script src="http://durated.github.io/angular-scroll/angular-scroll.min.js"></script>
<script src="../angular-scroll.js"></script>
<script>
angular.module('myApp', ['duScroll']).
controller('MyCtrl', function($scope){
Expand Down
3 changes: 2 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
top: 0;
left: 0;
right: 0;
background: #fff;
background: rgba(255, 255, 255, 0.8);
}
nav li, nav ul {
Expand Down Expand Up @@ -116,7 +117,7 @@ <h2>Section 4</h2>
</div>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
<script src="http://durated.github.io/angular-scroll/angular-scroll.min.js"></script>
<script src="../angular-scroll.js"></script>
<script>
angular.module('myApp', ['duScroll']).
controller('MyCtrl', function($scope, $document){
Expand Down
3 changes: 1 addition & 2 deletions src/directives/smooth-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ directive('duSmoothScroll', function(duScrollDuration, scrollContainerAPI){

return {
link : function($scope, $element, $attr){
var element = angular.element($element[0]);
element.on('click', function(e){
$element.on('click', function(e){
if(!$attr.href || $attr.href.indexOf('#') === -1) return;
var target = document.getElementById($attr.href.replace(/.*(?=#[^\s]+$)/, '').substring(1));
if(!target || !target.getBoundingClientRect) return;
Expand Down
9 changes: 4 additions & 5 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ run(function($window, cancelAnimation, requestAnimation, duScrollEasing) {
if(scrollAnimation) {
cancelAnimation(scrollAnimation);
}
var el = this;

var animationStep = function(timestamp) {
if (startTime === null) {
Expand All @@ -57,15 +58,13 @@ run(function($window, cancelAnimation, requestAnimation, duScrollEasing) {
var progress = timestamp - startTime;
var percent = (progress >= duration ? 1 : easing(progress/duration));

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

if(percent < 1) {
scrollAnimation = requestAnimation(animationStep);
}
}.bind(this);
scrollAnimation = (percent < 1 ? requestAnimation(animationStep) : null);
};

scrollAnimation = requestAnimation(animationStep);
};
Expand Down
2 changes: 1 addition & 1 deletion src/services/request-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ factory('polyfill', function($window) {
}
var suffix = fnName.substr(0, 1).toUpperCase() + fnName.substr(1);
for(var key, i = 0; i < vendors.length; i++) {
key = vendors[x]+suffix;
key = vendors[i]+suffix;
if($window[key]) {
return $window[key];
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/servicesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('service', function() {
timerCallback = jasmine.createSpy("timerCallback");
});

it('should be called within 20ms', function(done){inject(['requestAnimation',function(requestAnimation) {
it('should be called within 100ms', function(done){inject(['requestAnimation',function(requestAnimation) {
requestAnimation(timerCallback);
expect(timerCallback).not.toHaveBeenCalled();
setTimeout(function() {
Expand Down

0 comments on commit 46f2f4e

Please sign in to comment.