Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($sniffer): detect transition/animation on older Android browsers
Browse files Browse the repository at this point in the history
The stock Android browser doesn't support the current for-in body/style
detection for animations and transitions but we can manually fix this.
This is useful for PhoneGap web-views or traditional web-apps using the
stock browser.
  • Loading branch information
Julien Bouquillon authored and petebacondarwin committed Jul 3, 2013
1 parent 22b9b47 commit ef5bc6c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ng/sniffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function $SnifferProvider() {
}
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));

if (android && (!transitions||!animations)) {
transitions = isString(document.body.style.webkitTransition);
animations = isString(document.body.style.webkitAnimation);
}
}


Expand Down
44 changes: 44 additions & 0 deletions test/ng/snifferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ describe('$sniffer', function() {
expect($sniffer.animations).toBe(true);
});
});

it('should be true on android with older body style properties', function() {
module(function($provide) {
var doc = {
body : {
style : {
webkitAnimation: ''
}
}
};
var win = {
navigator: {
userAgent: 'android 2'
}
};
$provide.value('$document', jqLite(doc));
$provide.value('$window', win);
});
inject(function($sniffer) {
expect($sniffer.animations).toBe(true);
});
});
});

describe('transitions', function() {
Expand Down Expand Up @@ -238,5 +260,27 @@ describe('$sniffer', function() {
});
});

it('should be true on android with older body style properties', function() {
module(function($provide) {
var doc = {
body : {
style : {
webkitTransition: ''
}
}
};
var win = {
navigator: {
userAgent: 'android 2'
}
};
$provide.value('$document', jqLite(doc));
$provide.value('$window', win);
});
inject(function($sniffer) {
expect($sniffer.transitions).toBe(true);
});
});

});
});

0 comments on commit ef5bc6c

Please sign in to comment.