├── README.md ├── css ├── demo.css └── modal.css ├── img └── bg.jpg ├── index.html └── js ├── draggabilly.pkgd.js └── modal.js /README.md: -------------------------------------------------------------------------------- 1 | # draggable-google-modal 2 | Simple draggable modal with pure Javascript, inspired by *Google* Modal. 3 | 4 | ___ 5 | 6 | ### Features 7 | 8 | * Without external dependencies. 9 | * Drag and Drop 10 | * When is fixed, the drag is disabled. 11 | * Responsive 12 | * Shortcuts 13 | * Ctrl + **Up** Arrow: Fill the entire screen; 14 | * Ctrl + **Down** Arrow: Exit full screen; 15 | * Ctrl + **Left** Arrow: Align the left, filling half the screen*; 16 | * Ctrl + **Right** Arrow: Align the right, filling half the screen*; 17 | -------------------------------------------------------------------------------- /css/demo.css: -------------------------------------------------------------------------------- 1 | /* GENERAL */ 2 | *{ box-sizing: border-box;} 3 | 4 | html{ 5 | height: 100%; 6 | } 7 | body{ 8 | background: #f9f9f9 url("../img/bg.jpg") no-repeat left top; 9 | font-family: 'Lato', arial; 10 | } 11 | 12 | .btn-fixed{ 13 | position: fixed; 14 | left: 20px; 15 | bottom: 20px; 16 | } -------------------------------------------------------------------------------- /css/modal.css: -------------------------------------------------------------------------------- 1 | /* MODAL */ 2 | .modal-overlay{ 3 | visibility: hidden; 4 | opacity: 0; 5 | position: absolute; 6 | left: 0; 7 | top: 0; 8 | bottom: 0; 9 | right: 0; 10 | z-index: 98; 11 | } 12 | .modal{ 13 | visibility: hidden; 14 | opacity: 0; 15 | background: #fff; 16 | box-shadow: 0 4px 16px rgba(0,0,0,.2); 17 | border: 1px solid rgba(0,0,0,.333); 18 | width: 800px; 19 | height: 360px; 20 | position: absolute; 21 | left: 50%; 22 | top: 50%; 23 | margin-left: -400px; 24 | margin-top: -180px; 25 | z-index: 99; 26 | } 27 | .modal-body{ 28 | overflow-y: scroll; 29 | height: calc( 100% - 75px ); 30 | } 31 | .modal-content{ 32 | padding: 20px; 33 | transition: transform 0.7s cubic-bezier(0.165, 0.840, 0.440, 1.000); 34 | transform: translateY(-50px); 35 | } 36 | .modal.opening .modal-content{ 37 | transform: translateY(0px); 38 | } 39 | .modal-content p{ 40 | font-size: 15px; 41 | margin: 0 0 15px; 42 | } 43 | .modal-header{ 44 | transition: border-color 0.2s ease; 45 | box-sizing: border-box; 46 | background-color: #eee; 47 | border-bottom: 1px solid rgba(0,0,0,.2); 48 | font-size: 16px; 49 | height: 75px; 50 | line-height: 30px; 51 | margin: 0; 52 | padding: 22px 26px; 53 | vertical-align: middle; 54 | } 55 | .modal-header-title{ 56 | float: left; 57 | margin: 0; 58 | padding: 0; 59 | font-size: 15px; 60 | line-height: 28px; 61 | font-weight: 400; 62 | letter-spacing: -0.03em; 63 | cursor: default; 64 | } 65 | .modal-header-btn{ 66 | float: right; 67 | background-color: #4d90fe; 68 | background-image: -webkit-linear-gradient(top,#4d90fe,#4787ed); 69 | background-image: linear-gradient(top,#4d90fe,#4787ed); 70 | border: 1px solid #3079ed; 71 | color: #fff; 72 | border-radius: 2px; 73 | font-size: 11px; 74 | font-weight: 600; 75 | text-align: center; 76 | white-space: nowrap; 77 | margin-left: 5px; 78 | line-height: 26px; 79 | min-width: 70px; 80 | outline: 0; 81 | padding: 0 12px; 82 | cursor: pointer; 83 | } 84 | .modal-header-btn:hover{ 85 | opacity: 0.8; 86 | } 87 | .modal-header-btn:active { 88 | box-shadow: inset 0 1px 2px rgba(0,0,0,0.3); 89 | background: #357ae8; 90 | border: 1px solid #2f5bb7; 91 | border-top: 1px solid #2f5bb7; 92 | } 93 | 94 | /* STATUS */ 95 | 96 | .modal.is-full{ 97 | left: 0 !important; 98 | top: 0 !important; 99 | width: calc(100% - 30px) !important; 100 | height: calc(100% - 30px) !important; 101 | margin: 15px !important; 102 | } 103 | .modal.is-left{ 104 | left: 0px !important; 105 | right: auto !important; 106 | top: 0px !important; 107 | margin: 0px !important; 108 | height: 100% !important; 109 | } 110 | .modal.is-left{ 111 | left: 0px !important; 112 | right: auto !important; 113 | top: 0px !important; 114 | margin: 0px !important; 115 | height: 100% !important; 116 | } 117 | .modal.is-right{ 118 | left: auto !important; 119 | right: 0px !important; 120 | top: 0px !important; 121 | margin: 0px !important; 122 | height: 100% !important; 123 | } 124 | .modal.is-dragging{ 125 | border-color: #66afe9; 126 | outline: 0; 127 | box-shadow: 0 0 8px rgba(102,175,233,.6), 0 6px 20px rgba(0,0,0,.2); 128 | } 129 | .modal.opening, .modal-overlay.opening{ 130 | -webkit-animation: show 0.5s ease; 131 | animation: show 0.5s ease; 132 | -webkit-animation-fill-mode: forwards; 133 | animation-fill-mode: forwards; 134 | } 135 | .modal.closing, .modal-overlay.closing{ 136 | -webkit-animation: hide 0.5s ease; 137 | animation: hide 0.5s ease; 138 | -webkit-animation-fill-mode: forwards; 139 | animation-fill-mode: forwards; 140 | } 141 | @keyframes show { 142 | 0% { opacity: 0; } 143 | 100% {opacity: 1; } 144 | } 145 | @-webkit-keyframes show { 146 | 0% { opacity: 0; }.modal-header-title 147 | 100% { opacity: 1; } 148 | } 149 | @keyframes hide { 150 | 0% { opacity: 1; } 151 | 100% { opacity: 0; } 152 | } 153 | @-webkit-keyframes hide { 154 | 0% { opacity: 1; } 155 | 100% { opacity: 0; } 156 | } 157 | 158 | @media only screen and (max-width : 800px) { 159 | 160 | .modal{ 161 | width: 100%; 162 | left: 0 !important; 163 | margin-left: 0 !important; 164 | } 165 | 166 | } 167 | 168 | /* SCROLL */ 169 | .modal ::-webkit-scrollbar { 170 | overflow: visible; 171 | height: 13px; 172 | width: 14px; 173 | } 174 | .modal ::-webkit-scrollbar-thumb { 175 | background-color: rgba(0,0,0,.2); 176 | background-clip: padding-box; 177 | border: solid transparent; 178 | border-width: 3px; 179 | min-height: 28px; 180 | padding: 100px 0 0; 181 | box-shadow: inset 1px 1px 0 rgba(0,0,0,.1),inset 0 -1px 0 rgba(0,0,0,.07); 182 | } 183 | .modal ::-webkit-scrollbar-thumb:active { 184 | background-color: rgba(0,0,0,.4); 185 | } 186 | .modal ::-webkit-scrollbar-button { 187 | height: 0; 188 | width: 0; 189 | } 190 | .modal ::-webkit-scrollbar-track { 191 | background-clip: padding-box; 192 | border: solid transparent; 193 | border-width: 0 0 0 4px; 194 | } -------------------------------------------------------------------------------- /img/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcelodolza/draggable-google-modal/4bb0e2aac1cff3483447c66f9bd719d6b738cc4c/img/bg.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |