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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:55:28+00:00 2026-05-28T18:55:28+00:00

UPDATE: I have given this a couple shots to no avail! Right now in

  • 0

UPDATE: I have given this a couple shots to no avail! Right now in my jsfiddle I have my work so far.

http://jsfiddle.net/virtuapete/x2pnC/2/

Below is the code used to “center” the “home” div. Looking at it I realized its not aware of where the “home” div is currently located, therefore it blindly applies movement based on the array positioned with its origin in view in the upper left.

    container.overscroll({
    showThumbs:  false,
    scrollLeft:  1125,
    scrollTop:   1125
});

// Center "home" div in viewport
var gear = $('#gear');
gear.click(function() {
    var $foo = $('.id0'),
        elWidth = $foo.width(),
        elHeight = $foo.height(),
        elOffset = $foo.offset();
    container
        .scrollTop(elOffset.top + elHeight/2 - viewportHeight/2)
        .scrollLeft(elOffset.left + elWidth/2 - viewportWidth/2);
});

In it you can see the colored div array does not start out centered (the center div is outlined with a red border, follow the arrow on the edge of the viewport to find it if you like), I wish it was. I found the options for Overscroll and there is a top & left offset for the starting position of the overscrolled object. Unfortunately it is asking for an integer for both in what looks like its use of JQuery scrollTop & scrollLeft. Maybe I can insert a pre-calculated variable in there instead of a straight integer? I currently have it set to 1125px for each to get it in the view port for now atleast.

Theoretically I think its finding out the coordinate of the center of the “home” div on overscrolled object and aligning that on top of the calculated coordinate for the center of the viewport. what does that look like programatically and is that the most efficient way of approaching the problem?

  • 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-28T18:55:29+00:00Added an answer on May 28, 2026 at 6:55 pm

    change elOffset = $foo.offset(); to elOffset = $foo.position()

    .offset() returns the position of an element relative to the visible area (viewport). .position() returns the position relative to the containing element (parent). that’s why you can’t calculate how much to scroll off to the left and top coz you got the wrong values.

    i cannot center it well though, must be the margins between boxes throwing me off target but here’s another part i changed:

    container.scrollTop(elOffset.top - ((viewportHeight - elHeight) / 2)).scrollLeft(elOffset.left);
    

    i updated fiddle here.

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

Sidebar

Related Questions

I have a query here regarding the value given to the update attribute of
I currently have a list of things to update in the given mysqli query:
UPDATE I have updated my code in response to @MichaelRushton comments. I am now
This is a learning project for me and I have made a couple of
I have been searching around for a bit now. I have tried a couple
I have been busy with the cakePHP framework for a couple of months now
For a couple of weeks now, I have been working on migrating my client
Update I have just tried Pinning my site to the Taskbar again (after removing
UPDATE: I have somewhat resolved the issue. Just in case if anyone runs in
UPDATE - I have fixed some mistakes in the code below and the images

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.