Saturday, 2 September 2017

Auto Scroll Draggable Div Control Using jQuery

9/02/2017 - By Pranav Singh 0

In this article I will show you how you can create auto scroll draggable div control  with auto scroll using jquery in your html, asp.net and mvc application.


So for this article first we will create a new html file and add the below reference into the page header.

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

Now we will create a div control for dragging it.

  <div id="divdraggable" class="ui-widget-content draggable">
        <p>Scroll Div Default Settings</p>
    </div>
    <div style="height: 3000px; width: 1px;"></div>

After this we will create a jQuery function for this function will make the div auto scrollable.

  <script>
        $(function () {
            $("#divdraggable").draggable({ scroll: true });
        });
    </script>

In above code I have used jquery ui draggable function. Now please check the complete code of the page.

<html lang="en">
<head>
    <title>Auto Scroll Draggable Div Control Using jQuery</title>
    <style>
        .draggable {
            width: 100px;
            height: 100px;
            padding: 0.5em;
            float: left;
            margin: 0 10px 10px 0;
            background-color: gray;
        }
    </style>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script>
        $(function () {
            $("#divdraggable").draggable({ scroll: true });
        });
    </script>
</head>
<body>

    <div id="divdraggable" class="ui-widget-content draggable">
        <p>Scroll Div Default Settings</p>
    </div>
    <div style="height: 3000px; width: 1px;"></div>
</body>
</html>

Now we have done run the application to check the output.


Tags: ,
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top