PageRenderTime 20ms CodeModel.GetById 37ms RepoModel.GetById 1ms app.codeStats 0ms

/1.3/api/source/drag.html

https://github.com/kissyteam/kissyteam.github.com
HTML | 80 lines | 74 code | 6 blank | 0 comment | 0 complexity | eac8eee9a904297494a9285d8181128f MD5 | raw file
Possible License(s): Apache-2.0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='global-property-'>/**
  19. </span> * @ignore
  20. * drag plugin for kissy component
  21. * @author yiminghe@gmail.com
  22. */
  23. KISSY.add('component/plugin/drag', function (S, RichBase, DD) {
  24. <span id='KISSY-Component-Plugin-Drag'> /**
  25. </span> * drag plugin for kissy component
  26. *
  27. * @example
  28. * KISY.use('overlay,component/plugin/drag,dd/plugin/proxy',
  29. * function(S,Overlay,DragPlugin,ProxyPlugin){
  30. * var o =new Overlay.Dialog({
  31. * plugins:[
  32. * new DragPlugin({
  33. * handles: [function(){ return o.get('header'); }],
  34. * plugins: [ProxyPlugin]
  35. * })
  36. * ]
  37. * })
  38. * // or
  39. * o.plug(new DragPlugin({
  40. * handles:[function(){ return o.get('header'); }]
  41. * });
  42. * });
  43. *
  44. *
  45. * @class KISSY.Component.Plugin.Drag
  46. * @extends KISSY.DD.Draggable
  47. */
  48. return DD.Draggable.extend({
  49. pluginId: 'component/plugin/drag',
  50. pluginBindUI: function (component) {
  51. var el = component.get('el'),
  52. self = this;
  53. self.set('node', el);
  54. // sync
  55. self.on(&quot;dragend&quot;, function () {
  56. var offset = el.offset();
  57. component.setInternal('xy', [offset.left, offset.top]);
  58. });
  59. },
  60. pluginDestructor: function () {
  61. this.destroy();
  62. }
  63. }, {
  64. ATTRS: {
  65. move: {
  66. value: 1
  67. }
  68. }
  69. });
  70. }, {
  71. requires: ['rich-base', 'dd/base']
  72. });</pre>
  73. </body>
  74. </html>