Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to capture swipe direction of IronSwipeableContainer event #118

Open
astevko opened this issue Apr 8, 2016 · 1 comment
Open

how to capture swipe direction of IronSwipeableContainer event #118

astevko opened this issue Apr 8, 2016 · 1 comment

Comments

@astevko
Copy link

astevko commented Apr 8, 2016

I posted this on Stackoverflow a couple of days ago but got little visibility and no response.
Perhaps it'll do better here.

How do I capture the direction of the swipe event in a IronSwipeableContainer ?

    @UiField IronSwipeableContainer swipeable;
    ...
    swipeable.addIronSwipeHandler(new IronSwipeEventHandler() {

        @Override
        public void onIronSwipe(IronSwipeEvent event) {                
            log.info("onIronSwiped! ");
        }
    });

It is in the js object. I just cannot figure out how to access it from java.
event_0_g$.nativeEvent_1_g$.detail.direction = "left"
for extra credit - How do I prevent the swipe from dismissing (swipe away) the container?

@cpboyd
Copy link

cpboyd commented Jan 9, 2017

I think the only way to handle this (with the current generated Java code) would be to write a JSNI function and pass it event.getNativeElement()

http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html

E.g.:

        public void onIronSwipe(IronSwipeEvent event) {                
            String direction = determineDirection(event.getNativeEvent());
        }
...
public static native String determineDirection(JavaScriptObject event) /*-{
  return event.detail.direction;
}-*/;

With regard to preventing dismissal, perhaps a better workflow would be to identify beforehand which containers shouldn't be dismissible and prevent swiping altogether by setting the element's class="disable-swipe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants