Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:47:42+00:00 2026-06-10T15:47:42+00:00

I’m building a webpage where you can scroll-sideways or use buttons for new pages

  • 0

I’m building a webpage where you can scroll-sideways or use buttons for “new pages” (note; when you use buttons, you slide through the previous pages with speed, it doesn’t load a new page).

When a designated page comes into view, it should trigger an animation I made with flash.
I converted it via swiffy, and it works. Triggering the animation works just fine but the problem is: when for example you press the button wich would lead you to the page AFTER the page with the animation, the “page” still triggers because its been in view one time.

Now I’m trying to use a timeOut to delay the animation so that when you scroll by it, it shouldn’t trigger except for when you linger on the page for more than X seconds.

Here’s my current script:

    var $AnimatieAan = false;
    var $Zichtbaar = false;
    $(window).scroll(function(){
        $e = $('#searchEngine');

        var visible = $(window).scrollLeft()+window.innerWidth>$e.offset().left&&$(window).scrollLeft()<$e.offset().left+$e.width();

            if(visible)
            {
                $Zichtbaar = true;
                var Timer = setTimeout(function()
                {
                    console.log('timerstart');

                    if($Zichtbaar)
                    {
                        //$Zichtbaar = true;
                        console.log($Zichtbaar)
                        $AnimatieAan = true;
                        $Zichtbaar = false;
                        if($AnimatieAan)
                        {
                            var stage = new swiffy.Stage(document.getElementById('searchEngine'), mexaleSearch);
                            stage.start();
                            console.log(visible);
                            $AnimatieAan = false;
                        }
                        else 
                        {
                            clearTimeout(Timer);

                            console.log('clearTimeout');
                            $Zichtbaar = false;
                            $AnimatieAan = false;
                            stage.stop();
                        }
                    }                       
                } , 2000 );
            }

Clarification on how the scrolling works, a working version is on http://www.mexale.com

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:47:43+00:00Added an answer on June 10, 2026 at 3:47 pm

    There are a few problems here.

    1. Because Timer is a local variable inside the scroll handler, you’ll get a fresh, totally unrelated variable every time a scroll event happens. That means that the value of Timer is not remembered from one event to the next. To fix this, make a single var Timer outside the scope of the scroll handler function.

    2. The scroll handler doesn’t do anything if visible turns out to be false. When the user scrolls so that the animation isn’t visible, you want two things to happen: (a) the timeout should be cancelled; (b) the swiffy animation should be stopped. Instead, nothing happens, because the if (visible) block doesn’t have an else block.

    3. At the point where the code says if($AnimatieAan), the variable $AnimatieAan is always true. (We just set it to true two lines before.) So the else block there can’t run; it’s impossible.

    The code you have in that else block looks about right, but it is definitely attached to the wrong if.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.