Jump to content
Search Community

invalid scrollTo tween value: [object Object]

raffademello
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Posted

Good Morning Guys;

 

I want to scroll the current article when I click to the next or prev link, but on console browser shows the following information :

invalid scrollTo tween value: [object Object]

 

The HTML Structure is :

 

                        <div class="mask-articles">
                                <article class="history-article-1">
                                </article>

                               <article class="history-article-2">
                                </article>

                               <article class="history-article-3">
                                </article>
                          </div>

 

and the JS

 

        /* Time Line Quem Somos*/
        var section = 0;
        var sectionTotal = $(".mask-articles > article").length - 1;
        var article = $(".mask-articles > article");

        console.log($(section));

        $(".prev-history").click(function (e) {
            e.preventDefault();

            if (section > 0) {
                section--;
            }
            TweenMax.to($(".mask-articles"),0.5,{scrollTo:{y:$(".history-article-"+section).offset.top}});
        })

        $(".next-history").click(function (e) {
            e.preventDefault();

            if (section < sectionTotal) {
                section++;
            }

                TweenMax.to($(".mask-articles"),0.5,{scrollTo:{y:$(".history-article-"+section).offset.top}});
            //TweenMax.to(window, 0.5, {scrollTo:{y:$("#div" + section).offset().top}});
        })

 

Somebody can help me ?

 

Thank you.

Posted

Hi raffademello  :)

 

you should to change offset.top to offset().top , and it seems your logic to increase/decrease is wrong too...

 

See the Pen AGgEL by anon (@anon) on CodePen.

 

for next time pls make a codepen demo for better response.... :)

  • Like 3
Posted

Hello  raffademello, and welcome to the GreenSock forum!

 

Without seeing your code live, it would be hard to see what you are seeing in context.

 

Looks like your offset is missing the parenthesis offset(), please see jQuery offset() docs.

Also here is an example of the GSAP ScrollToPlugin in action:

 

See the Pen AsLfc by jonathan (@jonathan) on CodePen.

 

Using window  for the tween target, your code in a codepen example (i didn't know what your css looks like):

 

See the Pen Akorc by jonathan (@jonathan) on CodePen.



If this doesn't help, here is a nice video by GreenSock on how to create a codepen demo example, so we can better help you!

Thanks!

 

Resources:

http://api.jquery.com/jquery/

  • Like 3
  • 4 months later...
Posted

I would like to add an observation about this error message, i was getting the same message when i was missing the correct import of the scrollTo plugin .js file, so if you get this problem and the tween values look right, take a look at that.

 

Awesome library, by the way.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...