├── license.txt ├── README.md ├── draggin.min.js └── draggin.js /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Christopher Nunes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Draggin.js 2 | A fully multi-platform Javascript library for quickly and easily creating interactive user interfaces. 3 | ## [DEMO](https://draggin.surge.sh) 4 | ## Inspiration 5 | This project was created with simplicity and abstraction in mind. Draggin.js is the first complete drag and drop library that you can use without writing a single line of Javascript. I wanted a library that I could use with ease, instead of spending extra time configuring a heavy library. 6 | ## Features 7 | - *SERIOUSLY* Lightweight (2.5kb when compressed) 8 | - **Fully** touch compatible 9 | - No need to write Javascript code 10 | - Once included, is **instantly** usable 11 | - Editable text! 12 | - Leverages GPU for increased performance 13 | - ***ZERO DEPENDENCIES*** 14 | - Written in vanilla Javascript 15 | - No extraneous CSS or JS needed 16 | ## Get Started 17 | To use the script, simply include it in your webpage in a ``` 20 | ``` 21 | ### OR 22 | 23 | Download the draggin.min.js file from this repository and include it in your webpage: 24 | ``` 25 | 26 | ``` 27 | ## Usage 28 | Draggin.js is designed with simplicity in mind. Once you have included the script in your page, all you have to do is render an element and give it a class of "draggable." 29 | ``` 30 |

Hello, World!

31 | ``` 32 | To use the editable text that is part of Draggin.js, use any text element and give it a class of "text. 33 | ``` 34 |

Hello, World!

35 |

Hello, World!

36 | Hello, World! 37 |
Hello, World!
38 | ``` 39 | All of the above are valid examples of editable text. You can also combine both classes for the intended experience. 40 | Simply click once to drag elements, and double click to edit text. 41 | ``` 42 |

Both tags work at the same time!

43 | ``` 44 | ## Future Developments 45 | - React.js Port 46 | - Resizable Elements 47 | - Elements change position when screen resizes 48 | 49 | Special thanks to **BrowserStack** for testing tools 50 | 51 | ![BrowserStack](https://i1.wp.com/www.diogonunes.com/blog/wp-content/uploads/2016/07/browserstack-logo.png?resize=210%2C69 "Special thanks to *BrowserStack* for testing tools") 52 | 53 | -------------------------------------------------------------------------------- /draggin.min.js: -------------------------------------------------------------------------------- 1 | document.body.onload=function(){var e=".draggable{cursor: move;display: inline-block;} .text{display: inline-block; cursor: move;} .text:focus{cursor: auto;} .text-wrapper{width: 100%;position: relative;} .wrap{position: absolute;margin: auto;top: 0;bottom: 0;left: 0;right: 0;}';",t=document.createElement("style");t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(t);var n,o,i=document.querySelectorAll(".draggable"),a=document.querySelectorAll(".text");z=1,editing=!1;var r=null;function s(e){event.target.classList.contains("text")||(editing=!1,editing&&n.blur())}document.body.addEventListener("mousedown",s),document.body.addEventListener("touchstart",s);for(var d=0;d