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

  • Home
  • SEARCH
  • 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 8174299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:25:01+00:00 2026-06-06T22:25:01+00:00

I have a function that counts the amount of visits a page has, and

  • 0

I have a function that counts the amount of visits a page has, and counts the amount of visits remaining to reach a certaing goal.
It’s like a countdown.
There is a “hidden” picture, and each time there is a new visit, part of the picture is shown.

I have simple JavaScript code that counts the visits and some CSS “unveils” the picture according to a percentage.

But now I need to make this “Unveiling” slow down, meaning less % of the remaining picture should be revealed as the visits get closer to the goal.

Right now this is all I can get out of my brain:

remaining_percentage_to_goal = (current_visits*100)/goal

div_height = (remaining_percentage_to_goal*image_height)/100

I could try something like:

slow_down_rate = 0.25 
div_height = div_height-(remaining_percentage_to_goal*slow_down_rate)

Of course this will never reach 100% of the image height so it occured to me that I could do a hardcoded fixed variable with an IF statement or something that removes the slow_down_rate when certain percentage is reached, but that’s doesn’t seem to be exactly the effect we are looking for. So I was wondering if there is a better or more elegant approach.

Thanks

  • 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-06T22:25:02+00:00Added an answer on June 6, 2026 at 10:25 pm

    Sounds like you want something like a logarithmic approach. For the sake of this answer, let’s assume your goal is 1500 visits (but this can be any number, of course). You know that for zero visits, you want zero percent showing, and for 1500 visits, you want 100% showing, so you know two points on your graph: (0,0) and (1500,1). To make the natural logarithm fit these parameters, you have to translate and scale it, so you have:

    f(x) = alpha*ln(x+beta)
    

    We know that ln(1)=0, so beta=1 is easy. We can also find alpha pretty easily by plugging in our second point:

    1500 = alpha*ln(1500+1)
    
    alpha = 1500 / ln(1500+1)
    

    Now if we graph that, we get:

    enter image description here

    Which looks like the function we want…it naturally slows down as it approaches the goal, but it still reaches it.

    Translating this into Javascript, you’d have:

    var goal = 1500;
    var alpha = goal / Math.log(goal+1);
    var percentVisible = alpha * Math.log(visits+1);
    

    I hope this helps!

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

Sidebar

Related Questions

I have a function (frequency) which that counts how many times each distinct value
I have a page with multiple lists. Each list has a different amount of
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have a function that accepts a class (not an instance) and, depending on
I have a function that is being called from different threads in the application.
I have a function that allows users to edit a row in a table
I have a function that is recursively calling itself, and i want to detect
I have a function that pulls rows from a database, the content->id and content->type

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.