Comments (1)
The docs indicate that rebind
will ...change areas that are already selected to be rendered with the new options.
Prior to commit 3de37f3 (line 723) this was true. However, in this commit, the behavior changed to not persist previously selected state and instead, completely rebuild Area Data items.
This change does appear intentional as the test case related to rebind
also changed (Line 336). The test case itself incorporates singleSelect but there was no code modified/added to condition on singleSelect value so its difficult to know for certain if previous selected state should have been retained and just respected singleSelect somehow or if this test is just confirming that even when there are more than one areas configured with singleSelect === true
they are selected after rebind.
Given the code changes in rebind
method to call buildDataset and the fact that there is clearly no attempt to try to preserve state, the only logical conclusion was that the behavior was intentionally changed despite the fact that there was no major version update.
The net result of this commit is that rebind
& unbind
/init
are nearly identical with the only exception being the "prep" work of creating the wrapper, etc. This difference is actually the issue identified in #379.
Trying to find a reliable and deterministic approach to maintaining selected state while still respecting the options passed gets complicated and could lead to different behavior in certain situations. For example:
- How should
singleSelect
be treated iftrue
. If there are areas in config marked as selected, the any previous areas selected should be deselected and only the configured areas remain. If there are no areas configured as selected but more than one areas has a state of selected, which one remains selected? - If an area is configured as staticState (or it was configured but now isn't) how to adjust state accordingly
Based on all of this, shifting this issue from treating it as selected state should still be selected to the area should no longer be drawn since its no longer selected after a rebind
. In short, previous selected state is ignored and everything is based on current configuration passed. As mentioned, this minimizes the value of rebind but does stay consistent with the changes made in 3de37f3 by simply closing the gap/bug where the UI doesn't match internal selected state.
One additional note regarding behavior rebind - As written, it expects that the AREAS have not been modified in any way expect for the mapKey
and href
. It will ignore any other changes to the underlying HTML and in some cases (e.g. manual manipulation of coords) will cause unexpected results. This also means the order of the areas in the HTML should not change, no new areas should be added and no areas should be removed. If any of these changes are required, unbinding and re-initializing (e.g. $img.mapster('unbind').mapster({ ... })
) is required.
from imagemapster.
Related Issues (20)
- onGetList not called when isSelectable !== true
- tests not waiting for onConfigured before continuing
- [📘] rebind docs are not correct regarding preserving selected state
- jsFiddle demos are all broken HOT 6
- Incorrect reference to navigateMode config option name
- Safari's OCR/Live Text is blocking image zones HOT 3
- [TouchScreen only] Weird highlight glitch when touch on the other area beside the map. HOT 5
- this.activeToolTip.stop is not a function HOT 2
- Export image HOT 1
- Tooltip is inconsistent, it shows up on most areas but does not on couple of area item. HOT 5
- `Migrated tests` fail when running against zepto HOT 1
- [🐞] `navigate` example pages are unresponsive HOT 1
- [🐞] grunt `docco` task failing with `Fatal error: marked is not a function` HOT 1
- [✨] Improve ability to run tests with all supported libraries & versions
- [🐞] `configTimeout` not respected for value specified
- [✨] Add ESM support
- [🐞] `fadeDuration` specified in `area options` is not honored for tooltips
- [🐞] Forgotten console.log in v1.7.0 HOT 1
- [🐞] resizing map when map not visible causes `Failed to execute 'drawImage' on 'CanvasRenderingContext2D'` exception
- [🐞] exception `TypeError: Cannot read properties of null (reading '5')` encountered after `unbind`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imagemapster.