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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:10:48+00:00 2026-05-24T10:10:48+00:00

I am working on a project that uses a touch-screen interface. I have a

  • 0

I am working on a project that uses a touch-screen interface. I have a div inside of a smaller div, so the smaller div has scroll bars to access the rest of the first div. Here is the basic code for it.

.div1{
      height: 100px;
      width: 100px;
}
.div2{
      height: 50px;
      width: 50px;
}

and the html is:

<div id = "div2" class="div2">
 <div id="div1" class="div1"></div>
</div>

Using javascript, I would like to be able to scroll through div2 by pressing (since it is a touch screen) an unoccupied part of the screen and dragging along the div. Basically, the scroll feature would behave the way google maps does when you click and drag in it. Can anybody help me with this? Thanks in advance!

Note

In terms of mouse actions, pressing is equivalent to clicking here, just to be clear. I am also working in Firefox only, so cross-browser compatibility is not an issue.

  • 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-24T10:10:49+00:00Added an answer on May 24, 2026 at 10:10 am

    This works…I’d started making it for mobile safari before you cited FireFox…so it may have a little extra…

    var _startX = 0;
    var _startY = 0;
    var _offsetX = 0;			
    var _offsetY = 0;
    var _dragElement;
    document.onmousedown = OnMouseDown;
    document.onmouseup = OnMouseUp;
    
    function OnMouseDown(event){
      document.onmousemove = OnMouseMove;
        _startX = event.clientX;
      _startY = event.clientY;
      _offsetX = document.getElementById('div1').offsetLeft;
      _offsetY = document.getElementById('div1').offsetTop;
      _dragElement = document.getElementById('div1');
    
    }
    
    function OnMouseMove(event){
        _dragElement.style.left = (_offsetX + event.clientX - _startX) + 'px';
      _dragElement.style.top = (_offsetY + event.clientY - _startY) + 'px';
    }
    
    function OnMouseUp(event){
      document.onmousemove = null;
      _dragElement=null;
    }
    .div1{position:absolute; height:500px; width: 500px; z-index:1; background-color:red;}
    .div2{position:absolute; top:100px; left:100px; height:100px; width:100px; z-index:2; overflow:hidden; display:block;}
    <div class="div2" id="div2">
      <div class="div1" id="div1">
      </div>
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a large project that uses the STL and have a
I am working on a project that uses the asp.net ajax control toolkit and
I'm working on a project that uses an MDI application with a navigation panel
So I am working on a project that uses a ASP.NET server and we
I'm working on a source-code visualization project that uses the Processing core library. The
I am working on a software development project that uses code written primarily in
I am working a project that does not have a trunk / branches /
Working on a project that uses some IronPython scripts to as plug-ins, that utilize
I'm working on a project that uses MSTest for unit testing and I need
We are working on a project that uses Flex and rails with WebORB .

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.