Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
raffademello

invalid scrollTo tween value: [object Object]

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 4 months later...

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.

Link to comment
Share on other sites

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.
×