connectseekers.com

Friday, 20 March 2015

Auto Scroll While Dragging Item Using jQuery In Asp.Net MVC

3/20/2015 - By Pranav Singh 0

This article will show you how you can create auto scroll while dragging item using jquery in asp.net mvc. In this I have shown three type of scrolling facility
1     .       Scroll With Default Settings
2     .       Scroll With Sensitivity
3    .       Scroll With Scroll Speed


So for this article first I will create a new mvc application and add the below code into view. SO first I have added the jquery library.

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

Now here is the style sheet and the function.

<style>
    #draggableDiv, #draggable2Div, #draggable3Div
    {
        width: 100px;
        height: 100px;
        padding: 0.5em;
        float: left;
        margin: 0 10px 10px 0;
        background-color: Blue;
    }
</style>

<script>
    $(function () {
        $("#draggableDiv").draggable({ scroll: true });
        $("#draggable2Div").draggable({ scroll: true, scrollSensitivity: 200 });
        $("#draggable3Div").draggable({ scroll: true, scrollSpeed: 200 });
    });
</script>

Now here is the HTML

<div id="draggableDiv" class="ui-widget-content">
    <p>
        Scroll With Default Settings</p>
</div>
<div id="draggable2Div" class="ui-widget-content">
    <p>
        Scroll With Sensitivity - 200</p>
</div>
<div id="draggable3Div" class="ui-widget-content">
    <p>
        Scroll With Scroll Speed - 200</p>
</div>
<div style="height: 3000px; width: 100%; background-color: Yellow;"></div>

Now here is the complete code.

@{
    ViewBag.Title = "Auto Scroll While Dragging Item Using jQuery In Asp.Net MVC";
}

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<style>
    #draggableDiv, #draggable2Div, #draggable3Div
    {
        width: 100px;
        height: 100px;
        padding: 0.5em;
        float: left;
        margin: 0 10px 10px 0;
        background-color: Blue;
    }
</style>

<script>
    $(function () {
        $("#draggableDiv").draggable({ scroll: true });
        $("#draggable2Div").draggable({ scroll: true, scrollSensitivity: 200 });
        $("#draggable3Div").draggable({ scroll: true, scrollSpeed: 200 });
    });
</script>

<div id="draggableDiv" class="ui-widget-content">
    <p>
        Scroll With Default Settings</p>
</div>
<div id="draggable2Div" class="ui-widget-content">
    <p>
        Scroll With Sensitivity - 200</p>
</div>
<div id="draggable3Div" class="ui-widget-content">
    <p>
        Scroll With Scroll Speed - 200</p>
</div>
<div style="height: 3000px; width: 100%; background-color: Yellow;"></div>

Now run the application and check the output.


 VIDEO ARTICLE

Please check the link for Youtube video.  http://youtu.be/6CWH_rlDzRI
DOWNLOAD

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
Email Id : contact@aspdotnet-pools.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


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top