diff options
| author | Julien Bouquillon | 2013-06-28 12:06:36 +0200 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-07-03 22:16:31 +0100 |
| commit | ef5bc6c7c3336a64bae64fe9739cb1789907c906 (patch) | |
| tree | 49fcf49655ac100076e51a8f2dbf50b1f7e1c827 | |
| parent | 22b9b4757610918456e3486deb514bcc60a08852 (diff) | |
| download | angular.js-ef5bc6c7c3336a64bae64fe9739cb1789907c906.tar.bz2 | |
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.
| -rw-r--r-- | src/ng/sniffer.js | 5 | ||||
| -rw-r--r-- | test/ng/snifferSpec.js | 44 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/ng/sniffer.js b/src/ng/sniffer.js index 86c8dd00..54e6e083 100644 --- a/src/ng/sniffer.js +++ b/src/ng/sniffer.js @@ -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); + } } diff --git a/test/ng/snifferSpec.js b/test/ng/snifferSpec.js index 5cdc8fd9..c9d0d5a8 100644 --- a/test/ng/snifferSpec.js +++ b/test/ng/snifferSpec.js @@ -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); + }); + }); + }); }); |
