Comments (8)
Hmm interesting, I'm getting that as well, but only in IE and Firefox (not in Chrome).
The problem lies in this part:
var test = $('<div/>').css({
position: 'absolute',
'font-size': '14.1px'
}).appendTo(document.body).get(0),
computedStyle = window.getComputedStyle( test, null );
It seems test
always returns undefined, but Chrome doesn't throw an exception, whereas Firefox and IE do.
I think the issue is that @multiformeingegno and I are including the script in the head of our html, instead of before the body end tag. In our case body doesn't exist yet, and appendTo(document.body)
returns undefined!
Let me just try to confirm this..
from bigtext.
Ok yeah, that was the problem - moving the script to before the body end tag worked. Not sure if you'd classify that as a bug or not! :)
from bigtext.
I can confirm this. The plugin is unusable on Firefox/Yosemite.
Here's the fix:
var computedStyle="";
try{
var test = $('<div/>').css({
position: 'absolute',
'font-size': '14.1px'
}).appendTo(document.body).get(0),
computedStyle = window.getComputedStyle( test, null );
}catch(e){
//do nothing
}
return computedStyle ? computedStyle.getPropertyValue( 'font-size' ) === '14px' : true;
from bigtext.
The plugin needs to run either on DOMContentLoaded
or onload
. I’ll probably build this into the plugin eventually so that it handles it transparently.
from bigtext.
I can confirm seeing this on Chrome beta 41.0.2272.74. An associate of mine on the same network, loading the same internal page not using the beta release of Chrome is not seeing this behavior.
from bigtext.
Window.getComputedStyle does not work when you use document.querySelector. it works when u use getElementById
from bigtext.
how to resolve this error in react?
from bigtext.
Window.getComputedStyle: Argument 1 is not an object.
from bigtext.
Related Issues (20)
- Does BigText work with <a href> links? HOT 1
- Not working with textarea HOT 1
- BigText taking ~5sec to apply after full site loads, Wordpress HOT 2
- BigText does not care about div height to set font-size
- Uncaught TypeError: Cannot read property 'BigText' of undefined
- "Re-BigText on Resize" is misleading
- passing in the window object
- BigText stops working when required font-size is less than 24px HOT 1
- The latest release is no longer compatible with jQuery 3 HOT 4
- Callback option
- Doesn't work out of the box with webpack.
- bigtext is not a function
- Word spacing goes wrong on iOS Safari
- word-spacing doesn't get adjusted properly in Safari HOT 1
- Not live update when resizing window
- Scroll up when resizing window
- Vertical spacing (line height) with BigText
- Font size is being set too large with embedded font face
- resize event is not properly calculating font size
- Initial text size wrong, but on resize it works HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigtext.