Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

is not a function #54

Closed
ease-space opened this issue Jul 6, 2019 · 4 comments
Closed

is not a function #54

ease-space opened this issue Jul 6, 2019 · 4 comments

Comments

@ease-space
Copy link

TypeError: objectFitPolyfill__WEBPACK_IMPORTED_MODULE_6___default(...) is not a function
Снимок
Снимок1

@golubvladimir
Copy link

import 'objectFitPolyfill';

@brycebenson
Copy link

You can use it like it this in React (with react-video):

helpers.js

import 'objectFitPolyfill';

export const vidHelper = () => {
	const vids = Array.from(document.querySelectorAll('.video-react-video'));
	vids.forEach(vid => {
		vid.setAttribute('data-object-fit', 'cover');
		vid.setAttribute('data-object-position', 'center center');
	})
	window.objectFitPolyfill();
};

Import that into your component/root component, and add :
myComp.js

import { vidHelper } from '../../helpers'
...

componentDidMount() {
    vidHelper();
  }

You''ll need babel-polyfill also in your app to get it all working in IE11.

@roydukkey
Copy link

We probably should be creating a @types/objectFitPolyfill package. http://blog.wolksoftware.com/contributing-to-definitelytyped

@cee-chen
Copy link
Owner

cee-chen commented Jan 27, 2021

Closing this issue as I've added @brycebenson's super helpful instructions + a link to his comment in the README (so this will hopefully trip up less folks going forward, apologies this took so long).

@roydukkey, I'd definitely be happy to take a PR for types, but not sure I have the bandwidth to do so myself - feel free to open a separate issue for that!

EDIT: I had a little bit of time today and turns out the typescript defs are much easier than I thought (no @types package needed either), since the polyfill is a super small global library. I've added a global.d.ts file as of version 2.3.4 that should quiet any Typescript complaints when using window.objectFitPolyfill().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants