locked
What's the principle of Image's swipe event?

    Question

  • I want to process the swipe event by myself.

    But the image's rolling isn't smooth like the default processing method.

    And next is my code:

    void MainPage::OnImage_ManipulationDelta(
    	Object^ sender,
    	ManipulationDeltaRoutedEventArgs^ e)
    {
    	m_yOffset = scrollViewer->VerticalOffset - e->Delta.Translation.Y;
    
    	double fMaxHeight = scrollViewer->ScrollableHeight;
    	if (m_yOffset < 0) {
    		m_yOffset = 0;
    	} else if (m_yOffset > fMaxHeight) {
    		m_yOffset = fMaxHeight;
    	}
    
    	scrollViewer->ScrollToVerticalOffset(m_yOffset);
    
    	LogPrint(TEXT("ManipulationDelta: Originated Position:(%f, %f), IsInertial: %s, Translation.y: %.0f\n"),
    		e->Position.X, e->Position.Y,
    		e->IsInertial == true ? TEXT("True") : TEXT("False"),
    		e->Delta.Translation.Y
    		);
    
    	e->Handled = true;
    }

    Meanwhile, I got some test data like this:

    OnImage_ManipulationStarting -- Time: 13635281
    OnImage_ManipulationStarted
    ManipulationDelta: Originated Position:(1053.000000, 7845.000000), IsInertial: False, Translation.y: -21
    ManipulationDelta: Originated Position:(1047.000000, 7824.000000), IsInertial: False, Translation.y: -24
    ManipulationDelta: Originated Position:(1044.000000, 7800.000000), IsInertial: False, Translation.y: -22
    ManipulationDelta: Originated Position:(1056.000000, 7466.000000), IsInertial: False, Translation.y: -363
    ManipulationDelta: Originated Position:(1069.000000, 7761.000000), IsInertial: False, Translation.y: -40
    ManipulationInertiaStarting: Delta.y: 0, Trans.y: 0
    ManipulationDelta: Originated Position:(1069.000000, 7801.000000), IsInertial: True, Translation.y: 0
    OnImage_PointerReleased -- Time: 13635500
    ManipulationDelta: Originated Position:(1069.000000, 7409.000000), IsInertial: True, Translation.y: -393
    ManipulationDelta: Originated Position:(1069.000000, 7426.000000), IsInertial: True, Translation.y: -375
    ManipulationDelta: Originated Position:(1069.000000, 7463.000000), IsInertial: True, Translation.y: -338
    ManipulationDelta: Originated Position:(1069.000000, 7704.000000), IsInertial: True, Translation.y: -97
    ManipulationDelta: Originated Position:(1069.000000, 7623.000000), IsInertial: True, Translation.y: -178
    ManipulationDelta: Originated Position:(1069.000000, 7746.000000), IsInertial: True, Translation.y: -55
    ManipulationDelta: Originated Position:(1069.000000, 7723.000000), IsInertial: True, Translation.y: -78
    ManipulationDelta: Originated Position:(1069.000000, 7759.000000), IsInertial: True, Translation.y: -42
    ManipulationDelta: Originated Position:(1069.000000, 7729.000000), IsInertial: True, Translation.y: -73
    ManipulationDelta: Originated Position:(1069.000000, 7781.000000), IsInertial: True, Translation.y: -21
    ManipulationDelta: Originated Position:(1069.000000, 7763.000000), IsInertial: True, Translation.y: -38
    ManipulationDelta: Originated Position:(1069.000000, 7697.000000), IsInertial: True, Translation.y: -105
    ManipulationDelta: Originated Position:(1069.000000, 7779.000000), IsInertial: True, Translation.y: -23
    ManipulationDelta: Originated Position:(1069.000000, 7778.000000), IsInertial: True, Translation.y: -24
    ManipulationDelta: Originated Position:(1069.000000, 7780.000000), IsInertial: True, Translation.y: -21
    ManipulationDelta: Originated Position:(1069.000000, 7778.000000), IsInertial: True, Translation.y: -23
    ManipulationDelta: Originated Position:(1069.000000, 7779.000000), IsInertial: True, Translation.y: -23
    ManipulationDelta: Originated Position:(1069.000000, 7796.000000), IsInertial: True, Translation.y: -6
    ManipulationDelta: Originated Position:(1069.000000, 7798.000000), IsInertial: True, Translation.y: -4

     how system  identify the value of Translation.y.

    Monday, November 12, 2012 7:03 AM