Skip to main content
Home Forums Silverlight Programming Programming with JavaScript Auto window scrolling....
1 replies. Latest Post by SharpGIS on June 14, 2009.
(0)
CarlBrui...
Member
32 points
30 Posts
06-13-2009 8:18 PM |
Hi All,
I have a Silverlight canvas which has draggable objects on it, as the canvas width is greater than the horz. res I have horz. scroll bars.
I have a peice of JS that is updated with the location of a card and if it is being dragged then the window will auto scroll accordingly, the problem is that when I drag an object to the right, the scroll rate is way to quick and jagged, but when I drag a object left the scroll rate is very slow.
Here is the JS;
function getSilverlightMouse(xCoor) { window.scrollTo(xCoor, 0); }
I use the following code in the XAML code behind to call the JS (this code sits in my object_MouseMove method);
If point.X > 15 Then HtmlPage.Window.CreateInstance("getSilverlightMouse", point.X - 15) Else HtmlPage.Window.CreateInstance("getSilverlightMouse", 0) End If
Does anyone know how to improve the above code so that scrolling either to the left or right will be done at the same rate? Or how to make things more smooth?
I've seen a scrollby JS method, but I'm not sure this offers me any benefits.
Cheers
Carl[::TILL THE END::]
SharpGIS
Contributor
3387 points
611 Posts
06-14-2009 10:31 PM |
The speed difference makes sense, considering you are changing the coordinates underneath the mouse. Either you should take that into account, or you should handle the scrolling inside Silverlight instead of the JavaScript level. In Silverlight it's pretty easy to convert relative coordinates between elements using TransformToVisual.