fix($sniffer): detect transition/animation on older Android browsers

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.
This commit is contained in:
Julien Bouquillon 2013-06-28 12:06:36 +02:00 committed by Pete Bacon Darwin
parent 22b9b47576
commit ef5bc6c7c3
2 changed files with 49 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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() {
@ -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);
});
});
});
});