-
Notifications
You must be signed in to change notification settings - Fork 39
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
MAP areas only activate after browser refresh #20
Comments
Hello @edwardkeay, can you please provide a demo of it? |
Hi, Not sure if this is what you meant but please see attached a demo, 20210830_react-img-mapper_bug_video.mp4 |
hi, I have put the code in CodeSandbox I have never used it before and don't know how to get it to work, but the code is there https://codesandbox.io/s/ek-react-image-map-tl9or?file=/src/App.tsx |
Please try to run this code in code sandbox, I tried to fork it and run it but the code has many problems, so please try to run this code. As per your question, I thought the problem is it not working after deployment on the server but perfectly running on the development environment. My solution is to console the area array, it's getting into the |
HI, after some testing and trial and error, I have found it is an issue with the 'responsive' function I had the responsive set to true and set the parent width, this was causing the issue I have rectified it by calculating the ratio between the webpart width (i've set the webpart to be 100% width of the section) and the original image width., then using the ratio to calculate the new coordinates. This works perfectly, and does not have the issue regarding refreshing the page `const imgRatio = (this.props.webPartWidth / this.state.imageOriginalWidth); this.setState({scaleRatio: imgRatio}, () => {console.log("ReactImageMap - getMapInfo - setState scaleRatio: " + this.state.scaleRatio)}); var MapInfoCoords = mapinfo.Coords; let newCoords = splitCoords.map((origCoords, j) => {return (origCoords * imgRatio)}); var arr = new Array(newCoords); |
I am glad that you solved your problem on your own. |
Hi @NishargShah , this is a standard problem occurring in react. I am facing the same problem when using the responsive=true property. |
Can you please share the demo with me? |
here you go. The first time you view it when you hover over an area it won't highlight. On line 51 change parent width and either increase it by 1 or decrease, save it. and then it will start to hover on areas. https://codesandbox.io/s/agitated-cache-yuor3?file=/src/RadioboxContainer.jsx |
Thanks for the working example, I will look into that issue and get back to you |
Please upgrade your version to Codesandbox: https://codesandbox.io/s/small-sun-u804r Thanks |
The issue is solved. Thank you |
I have a problem, i use react-img-mapper, |
@majilan37 try to enable the const URL = 'https://raw.githubusercontent.com/img-mapper/react-docs/master/src/assets/example.jpg';
const MAP = {
name: 'my-map',
// GET JSON FROM BELOW URL AS AN EXAMPLE
areas: 'https://raw.githubusercontent.com/img-mapper/react-docs/master/src/assets/example.json',
};
<ImageMapper src={URL} map={MAP} natural stayHighlighted /> |
Describe the bug
I have created a react webpart utilising the react-img-mapper,
I collect the MAP data from some PropertyFieldCollectionData fields then build the MAP const based the fields values
During gulp serve testing, this works perfectly, however when I deploy to a site collection and configure the webpart part, on the first visit to the page the image displays but the MAP areas do not work.
After a refresh (F5) of the browser the MAP areas work, however if I do a hard refresh of the browser (CTRL+ F5) or close the browser and go back to the page the MAP areas are inactive again.
I know the MAP const has been created due to the console.log displayed in the render area.
This is the code I am using in the .tsx file
Webpart .tsx code
`
export interface IReactImageMapState {
mapArray: string;
}
export default class ReactImageMap extends React.Component<IReactImageMapProps, IReactImageMapState > {
}
`
Expected behavior
Expected behaviour is that on the first visit to the page the MAP areas work
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: