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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:01:35+00:00 2026-06-14T23:01:35+00:00

See fiddle: http://jsfiddle.net/mrcarllister/Z2GjN/ Basically, I’ve got the click-drag-scroll working EXCEPT when you click and

  • 0

See fiddle: http://jsfiddle.net/mrcarllister/Z2GjN/

Basically, I’ve got the click-drag-scroll working EXCEPT when you click and drag on an anchor/link.

It only seems to be when the mouse cursor remains on the link on release that the url is followed (for instance if you drag far enough and the link is off the window, that works fine.)

;(function($){ 

$.fn.scrollsync = function( options ){
var settings = $.extend(
        {   
            targetSelector:':first',
            axis: 'xy'
        },options || {});


function scrollHandler(event) {
    if (event.data.xaxis){
        event.data.followers.scrollLeft(event.data.target.scrollLeft());
    }
    if (event.data.yaxis){
        event.data.followers.scrollTop(event.data.target.scrollTop());
    }
}

settings.target = this.filter(settings.targetSelector).filter(':first');
settings.followers=this.not(settings.target); // the rest of elements

settings.xaxis= (settings.axis=='xy' || settings.axis=='x') ? true : false; 
settings.yaxis= (settings.axis=='xy' || settings.axis=='y') ? true : false;
if (!settings.xaxis && !settings.yaxis) return;  

settings.target.bind('scroll', settings, scrollHandler);

};

})( jQuery ); 

;(function($){




$.fn.dragscrollable = function( options ){

var settings = $.extend(
    {   
        dragSelector:'>:first',
        acceptPropagatedEvent: true,
        preventDefault: true
    },options || {});


var dragscroll= {
    mouseDownHandler : function(event) {

        if (event.which!=1 ||
            (!event.data.acceptPropagatedEvent && event.target != this)){ 
            return false; 
        }


        event.data.lastCoord = {left: event.clientX, top: event.clientY}; 


        $.event.add( document, "mouseup", 
                     dragscroll.mouseUpHandler, event.data );
        $.event.add( document, "mousemove", 
                     dragscroll.mouseMoveHandler, event.data );
        if (event.data.preventDefault) {
            event.preventDefault();
            return false;
        }
    },
    mouseMoveHandler : function(event) { 


        var delta = {left: (event.clientX - event.data.lastCoord.left),
                     top: (event.clientY - event.data.lastCoord.top)};

        event.data.scrollable.scrollLeft(
                        event.data.scrollable.scrollLeft() - delta.left);
        event.data.scrollable.scrollTop(
                        event.data.scrollable.scrollTop() - delta.top);


        event.data.lastCoord={left: event.clientX, top: event.clientY}
        if (event.data.preventDefault) {
            event.preventDefault();
            return false;
        }

    },
    mouseUpHandler : function(event) { 
        $.event.remove( document, "mousemove", dragscroll.mouseMoveHandler);
        $.event.remove( document, "mouseup", dragscroll.mouseUpHandler);
        if (event.data.preventDefault) {
            event.preventDefault();
            return false;
        }
    }
}


this.each(function() {

    var data = {scrollable : $(this),
                acceptPropagatedEvent : settings.acceptPropagatedEvent,
                preventDefault : settings.preventDefault }

    $(this).find(settings.dragSelector).
                    bind('mousedown', data, dragscroll.mouseDownHandler);
});
}; 

})( jQuery ); 

​

I’m pretty sure I have to ‘return:false;’ for anchors but I’m not sure how to do it ONLY when drag/scrolling.

Any help would be appreciated.

EDIT – Ian’s suggestion worked but I just need a couple of amends:

  1. Only scroll up and down (not left or right)
  2. To be restricted to the content / div size – and to not scroll any further.

—>>>>>>>>>>>>>

Cheers,

Carl

  • 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-14T23:01:36+00:00Added an answer on June 14, 2026 at 11:01 pm

    Alright well the problem here is this uses mouse up and down to work, so you can either disable the anchor permanently or it’ll work, so you need to have some business logic to say when it’s on and off. If you want to edit dragscrollable, put this in the code and it’ll work

    http://jsfiddle.net/Z2GjN/33/

    I added

    event.data.initCoord = event.data.lastCoord
    

    to mouseDownHandler and I added

            if(event.data.lastCoord != event.data.initCoord){
                obj = $(this);
                $('a', obj).on('click', function(event) {
                 event.preventDefault();                      
                });
                setTimeout(function(){$('a', obj).off('click'); },300);
            }
    

    to mouseUpHandler and I turned on preventdefault

    $('#viewport, #inner').
            dragscrollable({dragSelector: '.dragger:first', preventDefault: true});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a menu with tiled images w/text under them. See Fiddle: http://jsfiddle.net/techydude/GF8tS/ Is
See the fiddle: http://jsfiddle.net/stefek99/9m5NZ/1/ Get the source: http://pastie.org/3654715 Chrome 17 : just works. IE
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
I have the following fiddle for people to see http://jsfiddle.net/defaye/DhaHP/4/ The result on full
First: please see this fiddle: http://jsfiddle.net/gamehelp16/77ssr/ So, these images: (source: placekitten.com ) Uses the
This fiddle works (see We Distribute under Products): http://jsfiddle.net/dgUFw/1362/ But on the page in
I have made the following fiddle: http://jsfiddle.net/hxQE4/ See how the right arrow pushes the
See this fiddle: http://jsfiddle.net/uqJHf/ I have set the first column to show up with
See my fiddle here http://jsfiddle.net/WEZVX/2/ Notice when you mouse over the marker, you see
Take a look at this fiddle: http://jsfiddle.net/PRz4G/ You can see four white points about

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.