Trying to implement panning/scroling
Posted: Sun Jun 29, 2014 5:15 pm
Hi all.
As I want more control about panning, and as the default panning provided doesn't work well, I tried to implement panning myself using gestures in FireMonkey. Here is what I got so far for the X axis only:
I basically adjust the maximum and minimum of my X axis approximately by the amount my finger goes left or right ... If anyone has a better suggestion, I am all ears!
Thanks a lot!
CJ
As I want more control about panning, and as the default panning provided doesn't work well, I tried to implement panning myself using gestures in FireMonkey. Here is what I got so far for the X axis only:
Code: Select all
procedure TMultiEPGFrame.FrameGesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
var
lGlobalWidth: Double;
lLocalWidth: Double;
begin
if EventInfo.GestureID = igiPan then
begin
lGlobalWidth := self.Width;
lLocalWidth := fChart.BottomAxis.Maximum - fChart.BottomAxis.Minimum;
if fLastPosition.X < EventInfo.Location.X then
begin
fChart.BottomAxis.Minimum := fChart.BottomAxis.Minimum -
((EventInfo.Location.X) / lGlobalWidth);
fChart.BottomAxis.Maximum := fChart.BottomAxis.Maximum -
((EventInfo.Location.X) / lGlobalWidth);
end
else
begin
fChart.BottomAxis.Minimum := fChart.BottomAxis.Minimum +
((EventInfo.Location.X) / lGlobalWidth);
fChart.BottomAxis.Maximum := fChart.BottomAxis.Maximum +
((EventInfo.Location.X) / lGlobalWidth);
end;
fLastPosition := EventInfo.Location;
end;
end;
Thanks a lot!
CJ