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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:51:58+00:00 2026-06-08T12:51:58+00:00

I created a code that it work as a movie because the pellicle is

  • 0

I created a code that it work as a “movie” because the “pellicle” is a long image that contain all iphone movement. For create a sense of movement as movie, this code add 500px on the backgroundPositionY, then it wait 30 ms and restarts this process.

The mechanism is simple but the code is too long especially when will use a function .toggle() that is serves for add an another function, that it create an opposite animation when you do another click.

/*animate*/
screen.toggle(function(e){
    var mov = 0;
    function cicloIphone(){
        if(mov>6000){
            mov=0;
        };
        iphone.css('backgroundPosition', '0 -'+mov+'px');
        mov += 500;

        if(mov<6000){
            window.setTimeout(function(){
                cicloIphone();
            }, 30);
        };
    };
    var timeoutIphone = window.setTimeout(function(){
        cicloIphone();
    },0);
},function(e){
    var mov = 5500;
    function cicloIphone(){
        if(mov>6000){
            mov=0;
        };
        iphone.css('backgroundPosition', '0 -'+mov+'px');
        mov -= 500;

        if(mov<6000){
            window.setTimeout(function(){
                cicloIphone();
            }, 30);
        };
    };
    var timeoutIphone = window.setTimeout(function(){
        cicloIphone();
    },0);
});

I want synthesize with the function animate() but not ricreate my effect because not jump from 500px than 1000px each 30ms, but is too fluid and increase pixel for pixel.

/*animate synthesized*/
screen.toggle(
    function(e){iphone.stop(true,true).animate({
        'backgroundPositionX':'0px',
        'backgroundPositionY':'-5500px'
    },3000)},function(e){iphone.stop(true,true).animate({
        'backgroundPositionX':'0px',
        'backgroundPositionY':'0px'
    },3000);
});
  • 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-08T12:51:59+00:00Added an answer on June 8, 2026 at 12:51 pm

    animate() is quite a complex and flexible function. It does meet your requirements, since you can provide the three pieces of information it needs to operate:

    • the property to animate,
    • the target value,
    • the duration of the animation.

    So it knows what to change, where to go and how long it should take to go there, but the actual way of going there does not satisfy your requirements in the default case. There is, however, no problem using animate() in this situation, as long as you provide it a custom easing function:

    $.extend($.easing, {
        movie: function(current, elapsed, start, delta, duration) {
            // Returns the completion ratio as a float in the [0..1] range.
            // (elapsed / duration) would be linear, so build discrete steps
            // by "snapping" elapsed to 30 ms intervals.
            return (Math.floor(elapsed / 30) * 30) / duration;
        }
    });
    

    Now you can write:

    screen.toggle(function() {
        iphone.stop(true, true).animate({
            backgroundPositionY: "-5500px"
        }, 330, "movie");
    }, function() {
        iphone.stop(true, true).animate({
            backgroundPositionY: "0px"
        }, 330, "movie");
    });
    

    And it should animate the background image by discrete steps every 30 milliseconds for 330 milliseconds, which seems to be the effect you’re looking for.

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

Sidebar

Related Questions

I have the this code that will create excel file and work sheet then
I've created this code branch so that if the permalink settings do no match
the javascript:alert code that is being dynamically created ONLY works if I use the
So I have some Objective-c code that was created in Xcode 3.1 on OSX
I am trying to run some javascript code that is created by my codebehind
I have a workflow that is created in code and a variable of type
so here's what's going on. I have a table that is created in code-behind
I've just created a little app that programmatically compiles code using the C# Compiler,
I've used the reachability code provided by apple and created a UIAlert that displays
I know that if I created a custom control, say MyLabel in App_Code ..

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.