fix(sticky-headers): add feature detection

Closes #290
This commit is contained in:
Adam Bradley
2015-10-15 23:24:37 -05:00
parent d3a40aedf3
commit d9e19d38ff
3 changed files with 64 additions and 25 deletions

View File

@@ -14,6 +14,7 @@ import {Events} from '../util/events';
import {NavRegistry} from '../components/nav/nav-registry';
import {Translate} from '../translation/translate';
import {ClickBlock} from '../util/click-block';
import {FeatureDetect} from '../util/feature-detect';
import {TapClick} from '../components/tap-click/tap-click';
import * as dom from '../util/dom';
@@ -34,8 +35,9 @@ export function ionicProviders(config) {
let events = new Events();
let tapClick = new TapClick(app, config, window, document);
let featureDetect = new FeatureDetect();
setupDom(window, document, config, platform);
setupDom(window, document, config, platform, featureDetect);
bindEvents(window, document, platform, events);
// prepare the ready promise to fire....when ready
@@ -46,6 +48,7 @@ export function ionicProviders(config) {
provide(IonicConfig, {useValue: config}),
provide(IonicPlatform, {useValue: platform}),
provide(TapClick, {useValue: tapClick}),
provide(FeatureDetect, {useValue: featureDetect}),
provide(Events, {useValue: events}),
IonicForm,
IonicKeyboard,
@@ -61,7 +64,7 @@ export function ionicProviders(config) {
}
function setupDom(window, document, config, platform) {
function setupDom(window, document, config, platform, featureDetect) {
let bodyEle = document.body;
if (!bodyEle) {
return dom.ready(function() {
@@ -96,22 +99,8 @@ function setupDom(window, document, config, platform) {
bodyEle.classList.add('enable-hover');
}
/**
* Hairline Shim
* Add the "hairline" CSS class name to the body tag
* if the browser supports subpixels.
*/
if (window.devicePixelRatio >= 2) {
var hairlineEle = document.createElement('div');
hairlineEle.style.border = '.5px solid transparent';
bodyEle.appendChild(hairlineEle);
if (hairlineEle.offsetHeight === 1) {
bodyEle.classList.add('hairlines');
}
bodyEle.removeChild(hairlineEle);
}
// run feature detection tests
featureDetect.run(window, document);
}