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

[🐞] imagemapster is not bound to an image map when imagemapster is "re"-initialized #427

Closed
techfg opened this issue Dec 31, 2024 · 0 comments · Fixed by #428
Closed
Labels

Comments

@techfg
Copy link
Collaborator

techfg commented Dec 31, 2024

Describe the bug

When mapster(options) is invoked multiple times on a valid image map, imagemapster is not bound to the map.

There are a couple of scenarios where this type of situation can occur:

  1. When mapster is called multiple times - this would be an uncommon pattern but possible nonetheless
          $('#frog-img').mapster({ ... });
          $('#frog-img').mapster({ ... });
  2. When mapster is called a subsequent time after an unbind is called - This would be a common pattern in React where a component could be mounted, unmounted & remounted (e.g., StrictMode in dev build).
          $('#frog-img').mapster({ ... });
          $('#frog-img').mapster('unbind');
          $('#frog-img').mapster({ ... });

Reproduction

Scenario 1: https://jsfiddle.net/techfg/gn10ahzk/latest
Scenario 2: https://jsfiddle.net/techfg/37nje6fs/latest

Steps to reproduce

  1. When mapster is called multiple times - this would be an uncommon pattern but possible nonetheless

          $('#frog-img').mapster({ ... });
          $('#frog-img').mapster({ ... });

    Steps to reproduce
    Repro: https://jsfiddle.net/techfg/gn10ahzk/latest

    1. Open repro
    2. Hover over green buttons

    Expected Behavior
    Buttons should have a black shade

    Actual Behavior
    Buttons do not have black shade

  2. When mapster is called a subsequent time after an unbind is called - This would be a common pattern in React where a component could be mounted, unmounted & remounted (e.g., StrictMode in dev build).

          $('#frog-img').mapster({ ... });
          $('#frog-img').mapster('unbind');
          $('#frog-img').mapster({ ... });

    Steps to reproduce
    Repro: https://jsfiddle.net/techfg/37nje6fs/latest

    1. Open repro
    2. Hover over green buttons

    Expected Behavior
    Buttons should have a black shade

    Actual Behavior
    Buttons do not have black shade

Environment Info

Any OS, Any browser

Expected Behavior

Buttons should have a black shade

Additional Information

This appears to be a race condition so it does not occur every time although it occurs more often then not. If the subsequent call to mapster is deferred (e.g., setTimeout), the problem normally does not occur (depending on the size of image being loaded, duration of timeout, etc.).

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

Successfully merging a pull request may close this issue.

1 participant