Draggable - Automatically scroll the document when the draggable is moved beyond the viewport.


SUBMITTED BY: jlolk3r

DATE: Jan. 20, 2016, 4:52 a.m.

FORMAT: HTML

SIZE: 1.2 kB

HITS: 1132

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI Draggable - Auto-scroll</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  8. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="/resources/demos/style.css">
  10. <style>
  11. #draggable, #draggable2, #draggable3 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
  12. </style>
  13. <script>
  14. $(function() {
  15. $( "#draggable" ).draggable({ scroll: true });
  16. $( "#draggable2" ).draggable({ scroll: true, scrollSensitivity: 100 });
  17. $( "#draggable3" ).draggable({ scroll: true, scrollSpeed: 100 });
  18. });
  19. </script>
  20. </head>
  21. <body>
  22. <div id="draggable" class="ui-widget-content">
  23. <p>Scroll set to true, default settings</p>
  24. </div>
  25. <div id="draggable2" class="ui-widget-content">
  26. <p>scrollSensitivity set to 100</p>
  27. </div>
  28. <div id="draggable3" class="ui-widget-content">
  29. <p>scrollSpeed set to 100</p>
  30. </div>
  31. <div style="height: 5000px; width: 1px;"></div>
  32. </body>
  33. </html>

comments powered by Disqus