Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of directional zoom + pan via mouse drag (#421)
Summary: Added 2 features to the ImagePane Component. The first one allows to zoom on a particular area of the image (while keeping this area in the center of the visible part) The second allows to pan the image with the mouse drag action. Most of the changes are in ImagePane.js. Only two lines of css needed to be changed to allow zooming to work properly. Image interaction was quite poor so far : zoom and pan were not very user-friendly. #308 introduced image pan, but it used onWheel event, which did not allow for horizontal pan on desktop computers. In addition, it was not possible to zoom in a particular area of the image. I tested my changes by compiling the js code, running a visdom server, and displaying a saved visdom environment which included a visdom.image call. I am using a line of javascript which might not be very clean : ` this._paneRef._windowRef.children[1] ` at line 71 of file ImagePane.js, to get the top and left position of the Pane. There may be a cleaner way to get these but I couldn't find. As it uses some "hidden" attributes, it may not be very robust to future changes of React API. My changes should not modify existing features, apart from the zooming and panning speed that I increased in the handleZoom function (feel free to reset these constants to their previous value). I tried to run python example/demo.py but it failed with ```ConnectionRefusedError: [Errno 111] Connection refused```, both with and without my changes (after installing from sources). Not appropriate <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code follows the code style of this project. - [x] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] For JavaScript changes, I have re-generated the minified JavaScript code. Pull Request resolved: #421 Differential Revision: D8896258 Pulled By: JackUrb fbshipit-source-id: bcdcef3d621c99a3300ecac4246ba06cdd57a397
- Loading branch information