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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:30:49+00:00 2026-05-11T01:30:49+00:00

I’m trying to recreate the iPhone flick / scroll event in a window using

  • 0

I’m trying to recreate the iPhone flick / scroll event in a window using JavaScript.

Starting with JQuery, I’m measuring the mouse’s acceleration and offset during click – drag – release events using a timer:

var MouseY = {      init: function(context) {         var self = this;         self._context = context || window         self._down = false;         self._now = 0;         self._last = 0;         self._offset = 0;         self._timer = 0;         self._acceleration = 0;          $(self._context).mousedown(function() {self._down = true;});         $(self._context).mouseup(function() {self._down = false;});         $(self._context).mousemove(function(e) {self.move(e);});      },      move: function(e) {         var self = this;         self._timer++;         self._last = self._now;         self._now = e.clientY + window.document.body.scrollTop;         self._offset = self._now - self._last;         self._acceleration = self._offset / self._timer;     },      reset: function() {         this._offset = 0;         this._acceleration = 0;         this._timer = 0;     } };   $(function() {     MouseY.init();     setInterval(function() {         $('#info').html(             '_acceleration:' + MouseY._acceleration + '<br />' +             '_now:' + MouseY._now + '<br />' +             '_offset:' + MouseY._offset + '<br />' +             '_timer:' + MouseY._timer + '<br />'         );         MouseY.reset();     }, 10);  }); 

Now the problem is translating that acceleration into screen movement – are there any algorithms (easing?) or animation libraries that could help me out on this? (I’ve looked into JQuery’s .animate() but I’m unsure of how to apply it continuously during the drag events!

Update – final solution here:

http://johnboxall.github.com/iphone.html

  • 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. 2026-05-11T01:30:50+00:00Added an answer on May 11, 2026 at 1:30 am

    Hit up this link for the full explanation of one approach that seems to be what you’re looking for.

    http://www.faqts.com/knowledge_base/view.phtml/aid/14742/fid/53

    Here’s an excerpt:

    This handler then sets up event capture for mouse movement and stores mouse cursor positions in variables mouseX and mouseY. It then starts the timer monitorMouse() which measures mouse cursor speed by sampling the values in these variables at regular intervals. The variables mouseLeft and mouseTop hold each samplings mouse positions and the sampling rate is set to 100 milliseconds in the variable monitor.timerDelay.

    And some of the author’s code:

    nn4 = (document.layers)? true:false; mouseLeft = mouseTop = mouseX = mouseY = 0; monitor = {     timerDelay:100,     moveLimit:2,     sampleLimit:10 };  function startMonitor(thisText) {     if (!tip) return;     toolTipText = thisText;     writeTooltip(toolTipText);      document.captureEvents(Event.MOUSEMOVE);     document.onmousemove = function (evt) {         mouseX = evt.pageX;         mouseY = evt.pageY;         return true;     }     monitorMouse(); }  function stopMonitor() {     if (!tip) return;     hideTooltip();         if (monitor.timer) {         clearTimeout(monitor.timer);         monitor.timer = null;     }     document.releaseEvents(Event.MOUSEMOVE);     document.onmousemove = null;     monitor.slowSamples = 0; }  function monitorMouse() {     if (Math.abs(mouseX - mouseLeft)   > monitor.moveLimit         || Math.abs(mouseY - mouseTop) > monitor.moveLimit)     {         monitor.slowSamples = 0;     }     else if (++monitor.slowSamples > monitor.sampleLimit) {         showTooltip();         return;     }     mouseLeft = mouseX;     mouseTop  = mouseY;     monitor.timer = setTimeout('monitorMouse()',monitor.timerDelay); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 155k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Not as nice as you are asking about, but apropos… May 12, 2026 at 10:44 am
  • Editorial Team
    Editorial Team added an answer You have to get form by id, not by name.… May 12, 2026 at 10:44 am
  • Editorial Team
    Editorial Team added an answer Given that Scala runs on the Java Virtual Machine (JVM),… May 12, 2026 at 10:44 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.