REMOVE chrome shadow fixer

This commit is contained in:
salomonelli 2017-09-18 20:35:19 +02:00
parent b81818f328
commit 11ac16aee8
3 changed files with 56 additions and 3 deletions

View File

@ -13,7 +13,6 @@
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
},
"dependencies": {
"chrome-shadow-fixer": "^1.0.1",
"font-awesome": "^4.7.0",
"material-design-icons": "^3.0.1",
"material-icons": "^0.1.0",

View File

@ -0,0 +1,49 @@
const getElements = elements => {
if (elements && elements.length > 0) return elements;
elements = document.getElementsByTagName('*');
let ret = [];
for (const element of elements) {
const style = window.getComputedStyle(element, null).getPropertyValue('box-shadow');
if (style !== 'none') {
element.style.boxShadow = 'none';
ret.push({
shadow: style,
top: element.offsetTop + 'px',
left: element.offsetLeft + 'px',
width: element.getBoundingClientRect().width + 'px',
height: element.getBoundingClientRect().height + 'px'
});
}
}
return ret;
};
const generateElements = elements => {
let ret = '<div id="chrome-shadow-fixer">';
elements.forEach((el, i) => (ret += '<div id="chrome-shadow-fixer-' + i + '"></div>'));
ret += '</div>';
return ret;
};
export const fix = elements => {
const elementsWithShadows = getElements(elements);
if (elementsWithShadows.length < 1) {
console.warn('fixShadows(): No elements to fix shadows.');
return;
}
const generatedElements = generateElements(elementsWithShadows);
document.body.innerHTML += generatedElements;
elementsWithShadows.forEach((el, i) => {
const element = document.querySelector('#chrome-shadow-fixer-' + i);
element.style.height = el.height;
element.style.width = el.width;
element.style.left = el.left;
element.style.top = el.top;
element.style.position = 'absolute';
element.style.boxShadow = el.shadow;
element.style['-webkit-print-color-adjust'] = 'exact';
element.style['-webkit-filter'] = 'opacity(1)';
});
return elementsWithShadows;
};

View File

@ -10,12 +10,17 @@
<script>
import Vue from 'vue';
import * as chromeShadowFixer from 'chrome-shadow-fixer';
// import * as chromeShadowFixer from 'chrome-shadow-fixer';
import * as chromeShadowFixer from './chromeShadowFixer';
import '../resumes/resumes';
export default Vue.component('resume', {
name: 'app',
mounted: () => {
chromeShadowFixer.fix();
const els = chromeShadowFixer.fix();
if (
els &&
els.length > 0
) window.onhashchange = () => { location.reload(); };
}
});
</script>