Tuesday, February 3, 2015

Re: GWT and Javascript JSNI for Scroll To Top Button

I think the problem is in "this" keyword.

You can try to change your function with a Element param; like this.

public static native void fadeInOutAction(Element e) /*- {
if ($wnd.$(e).scrollTop() > 100) { ... }
else { ... }
}-*/

and the call in java code

faceInOutAction(myWidget.getElement());





Il giorno martedì 3 febbraio 2015 15:30:32 UTC+1, clg ha scritto:
Hello,

I'm trying to integrate a jQuery code in my GWT application without success for a button to top:

        public static native void fadeInOutAction() /*-{

                // back-to-top

                if ($wnd.$(this).scrollTop() > 100) {


                        $wnd.$('.scrollToTop').fadeIn();


                } else {


                        $wnd.$('.scrollToTop').fadeOut();


                }

       }-*/;


It seems not to detect the scroll event or my code is wrong.

Here is the original code for HTML CSS Javascript : http://www.paulund.co.uk/how-to-create-an-animated-scroll-to-top-with-jquery

The scroll to top action works great but when I want to display the button when I scroll to down, the button stay hidden.

Can you help me to understand?

Thank you.



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment