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

The plugin is not working initially #115

Open
ghost opened this issue Dec 6, 2017 · 1 comment
Open

The plugin is not working initially #115

ghost opened this issue Dec 6, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 6, 2017

I need it to work as soon as the page is loaded but it starts working after I resize the window.

How could it work the way I need in the demonstartion (http://mattstow.com/experiment/responsive-image-maps/rwd-image-maps.html) but not in my code?

@wardhache
Copy link

For anyone facing this issue now, I resolved it with using $(window).on('load') instead of $(document).ready().

I use this plugin together with maphilight to show my areas, and since it is 2019, I wanted to make it responsive. Obviously. Underneath the code I used. I hope it helps:

Javascript:

jQuery(document).ready(function(e) {
    var imageMapping = function() {
        $('#mapping').maphilight({
            stroke: true,
            strokeColor: '666666',
            strokeOpacity: 0.5,
            strokeWidth: 1,
            fill: true,
            fillColor: '666666',
            fillOpacity: 0.3,
            alwaysOn: true,
            wrapClass: 'map'
        });
    }

    $('#mapping').rwdImageMaps();

    $(window).on('load', imageMapping)
    $(window).on('resize', imageMapping);
});

CSS:

.map {
    background-size: contain !important;
    width: 100% !important;
    background-repeat: no-repeat !important;
}

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