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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:12:38+00:00 2026-05-31T22:12:38+00:00

I am trying to scroll by highlighting text and dragging down. Now, as you

  • 0

I am trying to scroll by highlighting text and dragging down. Now, as you are probably aware, this is standard, default behavior for a standard overflow: auto element, however I am trying to do it with some fancy scrollbars courtesy of jQuery jScrollPane by Kelvin Luck.

I have created a fiddle here: DEMO

basically as you can see, highlighting and scrolling works in the top box (the default overflow: auto box) but in the second it doesn’t and, to compound matters, once you reach the bottom it INVERTS your selection!

So, my question(s) is(are) this(these): is there a way to fix this? If so, how?

UPDATE

I have been working on this quite a bit and have found a slight solution using setTimeout()

however, it doesn’t work as intended and if anybody is willing to help I have forked it to a new fiddle here: jsFiddle

the code itself is:

pane = $('#scrolldiv2');
pane.jScrollPane({animateEase: 'linear'});
api = pane.data('jsp');

$('#scrolldiv2').on('mousedown', function() {
    $(this).off().on('mousemove', function(e) {
        rel = $(this).relativePosition();
        py = e.pageY - rel.y;
        $t = $(this);
        if (py >= $(this).height() - 20) {
            scroll = setTimeout(scrollBy, 400, 20);
        }
        else if (py < 20) {
            scroll = setTimeout(scrollBy, 400, -20);
        }
        else {
            clearTimeout(scroll);
        }
    })
}).on('mouseup', function() {
    $(this).off('mousemove');
    clearTimeout(scroll);
})

var scrollBy = function(v) {
    if (api.getContentPositionY < 20 & v == -20) {
        api.scrollByY(v + api.getContentPositionY);
        clearTimeout(scroll);
    } else if (((api.getContentHeight - $t.height()) - api.getContentPositionY) < 20 & v == 20) {
        api.scrollByY((api.getContentHeight - $t.height()) - api.getContentPositionY);
        clearTimeout(scroll);
    } else {
        api.scrollByY(v, true)
        scroll = setTimeout(scrollBy, 400, v)
    }
}

$.fn.extend({
    relativePosition: function() {
        var t = this.get(0),
            x, y;
        if (t.offsetParent) {
            x = t.offsetLeft;
            y = t.offsetTop;
            while ((t = t.offsetParent)) {
                x += t.offsetLeft;
                y += t.offsetTop;
            }
        }
        return {
            x: x,
            y: y
        }
    },
})​
  • 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-31T22:12:39+00:00Added an answer on May 31, 2026 at 10:12 pm

    You just have to scroll down/up depending on how close the mouse is to the end of the div; is not as good as the native solution but it gets the job done ( http://jsfiddle.net/PWYpu/25/ )

    $('#scrolldiv2').jScrollPane();
    
    var topScroll = $('#scrolldiv2').offset().top,
        endScroll = topScroll + $('#scrolldiv2').height(),
        f = ($('#scrolldiv2').height() / $('#scrolldiv2 .jspPane').height())*5 ,
        selection = false,
        _prevY;
    
    $(document).mousemove(function(e){
        var mY;
        var delta = _prevY - e.pageY;
        if((e.pageY < endScroll && (mY = ((e.pageY - endScroll + 80)/f)) > 0) || 
           (e.pageY > topScroll && (mY = (e.pageY - (topScroll + 80))/f) < 0)){
              if(selection && (delta > 10 || delta < -10) )
              $('#scrolldiv2').data('jsp').scrollByY(mY, false) ;
        } 
    })   
    
    $('#scrolldiv2').mousedown(function(e){_prevY = e.pageY; selection = true ;})
    $(window).mouseup(function(){selection = false ;})​
    

    BTW, the reason it inverts the selection is because it reached the end of the document, just put some white space down there and problem solved.

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

Sidebar

Related Questions

I am trying to auto scroll my text view and reset it to the
I am trying to trigger the onScroll event this way using prototype: Event.observe(document, 'scroll',
I am trying to auto-scroll to div using: /index.php#tabletabs2?contact_added=1 when I use: /index.php#tabletabs2 it
I am trying to scroll the picker view horizontally and this is my code.
I'm trying to scroll down and up with buttons. I wrote lot of code
I'm trying to scroll to bottom of a DataGridView in a C# WinForm. This
Still trying to figure this out from yesterday. I am trying to scroll an
I'm trying to use the infinite scroll AS3 I discuss in this SO question
I am trying to scroll text (list elements actually) from right to left. Here
I'm trying to make dynamic text scroll on the page. I want it to

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.