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

Resizing only considers first image referencing the image map #56

Open
rubenvarela opened this issue Jun 23, 2017 · 0 comments
Open

Resizing only considers first image referencing the image map #56

rubenvarela opened this issue Jun 23, 2017 · 0 comments

Comments

@rubenvarela
Copy link

I have a page that contains an image map. When you click on one of the areas, it changes the image. There is also different images for mobile and one for larger screens.

The current issues I have is that the code only takes into consideration the first image it finds per map and reuses this. In my case, the dimensions of that image when display:none is the original dimensions.

Here is the line it uses to define the image,

           image                 = document.querySelector('img[usemap="#'+map.name+'"]');

code reference

That first image, in my case, is the image for a larger screen which is hidden on mobile.

This function,

        function get_image() {
            var imageList = document.querySelectorAll('img[usemap="#'+map.name+'"]');
            var count = imageList.length;
            for (var i = 0; i < count; i++){
                var cImage = imageList[i].offsetParent;
                if (typeof cImage != undefined && cImage) {
                    return imageList[i];
                }
            }
        }

Works great for finding the first image on the image map that is not hidden.

Now, I'm trying to find the correct locations that need this call. The issue is that the previous line is defined under setup() which only runs once per page.

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

1 participant