I’m using Raphael to draw a figure. The figure is very large, so the browser window shows a scroll bar. Now I want a part of the figure to keep still even if the user moves the scroll bar. How could this be done?
In addition, I want to change the figure based on the position of the scroll bar (for example, showing the x-coordinate the scroll bar). Is this possible?
Thank you.
I’m using Raphael to draw a figure. The figure is very large, so the
Share
Here is the solution to my questions. To keep a part of the figure still regardless of scrolling, create two canvases, one for the part that shall move with scrolling and one for the still part. Then put the 2nd canvas in
<div style="position:fixed">.Here is the code:
Note that this code only works if the two parts of the figure are separate. I don’t know if they can still be drawn in two canvas if they overlap.
To change the figure based on the position of the scroll bar, use the following code. The getScrollX() function is adapted from the code at http://www.howtocreate.co.uk/tutorials/javascript/browserwindow.