Comments (10)
Thanks!
Regarding the selector: I mentioned you can pass the element since you might already have it available in a variable in the React component, without having to re-query the dom. But it works either way :)
from object-fit-images.
Are you using any other scripts like lazyload, React or similar code that changes the original <img>
tag? Perhaps any innerHTML
? How does the <img>
tag appear in the original HTML?
from object-fit-images.
I found my issue. I was using es6 import's but also loaded the library trough a script tag…
Thanks for the great polyfill 👍
from object-fit-images.
I'm encountering the exact same issue in IE11 in my React app. Here's what's being rendered:
<img class="ImageCardParallax--image--1RQt2 Parallax--full-width--3lsBj Parallax--full-height--XTQSz" style="background-position: center; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: contain; background-origin: content-box;" alt="fill-murray-1" src="http://www.fillmurray.com/300/300" data-ofi-src="http://www.fillmurray.com/300/300"></img>
My CSS looks like this:
.ImageCardParallax--image--1RQt2 {
object-fit: contain;
font-family: 'object-fit: contain;';
}
.Parallax--full-width--3lsBj {
width: 100%;
}
.Parallax--full-height--XTQSz {
height: 100%;
}
And I'm initializing it in my component (which is a pure functional component) like so:
objectFitImages('img.ImageCardParallax--image--1RQt2');
In the original HTML (or rather, JSX), the img
looks like this:
<img src="http://www.fillmurray.com/300/300" alt="fill-murray-1" className="ImageCardParallax--image--1RQt2 Parallax--full-width--3lsBj Parallax--full-height--XTQSz" />
Any ideas whats happening @bfred-it ?
from object-fit-images.
I think you should put the objectFitImages(el)
call in the componentWillMount
. Just pass the element, not a selector.
from object-fit-images.
@bfred-it I just converted my pure component to a React.Component class and moved the call into componentDidMount
, passing it an element instead. I'm still seeing the same behavior.
Also, don't the docs specify that you can pass in a selector rather than an element?
EDIT: I misread your comment initially. I have now tried a few things:
-
Moved
objectFitImages('img.ImageCardParallax--image--1RQt');
intocomponentDidMount
. Effect: same as before. -
Moved
const imgs = document.querySelectorAll('img.ImageCardParallax--image--1RQt2'); objectFitImages(imgs);
intocomponentDidMount
. Effect: same as before. -
Did same as (1) but in
componentWillMount
. Effect: now no styles are being applied (which makes sense, since the component hasn't been rendered yet at this point) -
Did same as (2) but in
componentWillMount
. Effect: same as (3)
(I'm also on version ^3.2.3
btw)
from object-fit-images.
@bfred-it Never mind...this turned out to be an issue with our deployment/build system, your polyfill works great. Thanks for bearing with me!
from object-fit-images.
Ah that’s good! What was the issue and where do you put the objectFitImages
call? The solution might help others
from object-fit-images.
Basically it ended up being just a series of debugging mishaps related to developing in internal NPM packages, bugs with npm update
, and testing all of this in IE11 in Browserstack -- the details of which are not important :)
To summarize though: initially, we had forgotten to include the CSS rule font-family: 'object-fit: contain;'
in our CSS. After we added that, the polyfill worked as expected. We included the objectFitImages
call immediately before the return value in our pure functional React component, and passed it the selector (see my earlier comment)
Hope this helps! Thanks again
from object-fit-images.
Ah, good call! Thanks :)
from object-fit-images.
Related Issues (20)
- Assignment to read-only properties is not allowed in strict mode HOT 2
- Load event handler should get called when backgroundImage style is rendered. HOT 1
- Changing the src results in a "data-ofi-undefined" attribute. HOT 1
- Media Query images using `<source>` tag not working HOT 2
- Assignment to read-only properties is not allowed in strict mode HOT 13
- Fix documentation on es6 import HOT 7
- How to use this in angular project? HOT 2
- Error during tests HOT 2
- Test in IE with version 3.2.4 HOT 1
- IE11: Including the polyfill in two different libraries via ES6 imports then including both onto the page breaks it HOT 2
- > Assignment to read-only properties is not allowed in strict mode
- Doesn't support Edge 15 HOT 1
- react how to use ,ie11 is not working? HOT 1
- cloudinary videos is not working in IE 11 i.e object fit HOT 1
- Unable to use with Next HOT 2
- A request to have a de-initialization (cleanup) API HOT 2
- Uncaught (in promise) TypeError: _objectFitImages2.default.objectFitImages is not a function HOT 1
- Uses src when image has srcset HOT 4
- <picture> element in Edge 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 object-fit-images.