Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
DNSalehi
Posts: 47
Registered: ‎01-26-2011
Accepted Solution

Swipe to next Page or ImageView

Is there a way we can create a side swipe to slide to the next page? Or even slide to the next imageview?

 

I'm creating a tutorial page for my app when its first loaded, and I want the user to be able to swipe to go to the next page/image of the tutorial. 

 

It would look pretty much like the home page of the BB10, where you can swipe to the next page of apps.

 

Please use plain text.
Developer
saprykin
Posts: 271
Registered: ‎05-29-2013
My Carrier: MTS

Re: Swipe to next Page or ImageView

There is no built-in swipe gesture handler in Cscades. But you can listen touch events on ImageView and handle swipe by yourself. Use TocuhEvent: https://developer.blackberry.com/cascades/reference/bb__cascades__touchevent.html
With it you can track finger movement and decide whether to swipe to next page or not.
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Please use plain text.
Developer
DNSalehi
Posts: 47
Registered: ‎01-26-2011

Re: Swipe to next Page or ImageView

That's odd seeing as how the OS revolves around swiping...

I don't think the TouchEvent would be the best route to take,
I need it to be like the home page of the BB10 where you can drag the screen and it snaps onto the next page.

I'm trying to implement this using a horizontal ScrollView but running into quite a few problems including the speed of the scroll being too fast that it flies by all the pages if the user tries to swipe.
Please use plain text.
Developer
saprykin
Posts: 271
Registered: ‎05-29-2013
My Carrier: MTS

Re: Swipe to next Page or ImageView

I would still recommend you to handle this trough TouchEvent. You should accumulate user movement and see if it has enough length and speed along X axis. If so, you can animate ImageView change.
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Please use plain text.
Developer
DNSalehi
Posts: 47
Registered: ‎01-26-2011

Re: Swipe to next Page or ImageView

I see what you mean, I'll give it a try but I originally wanted the screen to stick to the users swipe.
For example, from when the swipe starts to when it ends, the image wouldn't be moving.

But I guess I'll have to just resort to it animating after the swipe
Please use plain text.
Developer
saprykin
Posts: 271
Registered: ‎05-29-2013
My Carrier: MTS

Re: Swipe to next Page or ImageView

Yes, you can use either TranslateAnimation or you can move ImageViews accordingly values received from TouchEvents.
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Please use plain text.
Developer
DNSalehi
Posts: 47
Registered: ‎01-26-2011

Re: Swipe to next Page or ImageView

Awesome thanks I'll try it out!
Please use plain text.
New Member
geraldmmolina
Posts: 1
Registered: ‎08-21-2013
My Carrier: 9528385374

Re: Swipe to next Page or ImageView

Hi saprykin,

 

I am also trying to do the same "swipe to next page" and still have no luck. Can you share a simple code that uses the TranslateAnimation? my email add is geraldmmolina@gmail.com

 

Thanks

Please use plain text.