Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: driftImgs.map is not a function #680

Closed
dngraphisme opened this issue Nov 15, 2022 · 2 comments
Closed

TypeError: driftImgs.map is not a function #680

dngraphisme opened this issue Nov 15, 2022 · 2 comments

Comments

@dngraphisme
Copy link

dngraphisme commented Nov 15, 2022

Hello team @paulstraw ,

Thank you for the library however i have a problem that i can't solve.

I need to work on a viewer in my webpack stack for product sheet under Prestashop 1.7

If I use this code to do a foreach on several images

const driftImgs = document.querySelectorAll('.drift-img');
            console.log(driftImgs)
            const pane = document.querySelector('.drift-pane');
            driftImgs.map(img => {
                new Drift(img, {
                    paneContainer: pane,
                    inlinePane: false
                });
            });

I get this error: TypeError: driftImgs.map is not a function


I work with Jquery, so I tried an each function on the class: .drift-img

But there also impossible to instantiate the library.

Do you have an idea ?

Thank you in advance, regards Nicolas

@dngraphisme
Copy link
Author

Ok I got it with this code :

driftImgs.forEach(function (img) {
                 new Drift(img, {
                     paneContainer: pane,
                     inlinePane: false
                 });
             });

Thanks again :)

@atlawrie
Copy link
Contributor

Hello! I'm gonna go ahead and close this ticket since it looks like you've gotten it working; feel free to reopen if this is still posing problems.

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

No branches or pull requests

2 participants