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 3938542
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:11:48+00:00 2026-05-20T00:11:48+00:00

I have a simple animation on my rails site that pop’s a div (with

  • 0

I have a simple animation on my rails site that pop’s a div (with a logo image inside) from behind a div using the ‘animate‘ function in Jquery, which works great!

However, I can’t figure out how to get it to run exactly once on the landing page, and then make the div stay put across every other page and on page reload. Every page load across the whole site runs the animation every time. I put the JQuery div that gets animated inside the application.html.erb file, so it’
s part of the header for the whole-site template (which explains why it’s getting rendered in every view).

I know I could just copy and paste the code into a partials and make separate CSS entries for how the logo would display on each page, but I’m trying to keep my code DRY.

Here’s my javascript:

$(document).ready(function() 
 {
    $('.logo .active-image').animate({
       opacity:1,          //set opacity
       marginTop: "-90px", //move the image 'up' 90px
       }, 5000);           //animate over 5 secs
 });

And the logo image div on the whole site template:

<div class="logo">
     <%= image_tag("../images/logo.png", :class => 'flying-image active-image') %>
</div>

So is there a ‘Rails-y”, DRY, way to do this using just jquery?

  • 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-05-20T00:11:48+00:00Added an answer on May 20, 2026 at 12:11 am

    I see two possible solutions here. HTTP itself is stateless, but you need some state, e.g. “Is this the first page view of user X?”.

    Now you can either store a flag in your user’s session, or store it in a separate cookie. The latter would only involve JavaScript.

    Draft of a JavaScript/Cookie solution

    if (!$.cookie('visited_before')) {
        $('.logo .active-image').animate({
            opacity:1,          //set opacity
            marginTop: "-90px", //move the image 'up' 90px
            }, 5000
        );
        $.cookie('visited_before', true);
    }
    

    That’s just an example, using a pseudo jQuery cookie function. There are probably enough plugins for cookie handling.

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

Sidebar

Related Questions

I have this simple animation that moves an image from one point to another:
I have a simple jquery animation on a div, which is inside a div,
i have a very simple animation in flash CS4. My image travels from point
So I have been creating a simple animation that copies a div, and expands
I have a simple jQuery animation that moves a div to the right or
I have a simple JQuery animation that reduces the opacity of a div on
so i have a swf with a simple animation- the div used to contain
We have a simple animation that runs when a ToggleButton is checked and unchecked
I'm trying to do some simple animation. I have a UIViewController that has two
I have a simple jQuery animation using fadein and it works but once faded

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.