mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-10 07:44:43 +00:00
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:
parent
22b9b47576
commit
ef5bc6c7c3
2 changed files with 49 additions and 0 deletions
|
|
@ -37,6 +37,11 @@ function $SnifferProvider() {
|
||||||
}
|
}
|
||||||
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
|
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
|
||||||
animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,28 @@ describe('$sniffer', function() {
|
||||||
expect($sniffer.animations).toBe(true);
|
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() {
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue