UNPKG

area-selection-js

Version:

Simple and easy area selection library for image/video cropping

195 lines (170 loc) 3.02 kB
.area-selection-container * { user-select: none; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; } .area-selection-container img, .area-selection-container video { vertical-align: middle; max-width: 100%; } .area-selection { position: relative; display: inline-block; } .area-selection-overlay { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; cursor: crosshair; } .area-selection-region { background: rgba(51, 153, 255, 0.1); border: 1px dashed rgba(51, 153, 255, 0.5); position: absolute; z-index: 3; cursor: move; top: 0; } .area-selection-handle { background-color: #39f; width: 5px; height: 5px; opacity: .75; position: absolute; z-index: 4; } .area-selection-handle-e { cursor: ew-resize; margin-top: -3px; right: -3px; top: 50%; } .area-selection-handle-n { cursor: ns-resize; left: 50%; margin-left: -3px; top: -3px; } .area-selection-handle-w { cursor: ew-resize; left: -3px; margin-top: -3px; top: 50%; } .area-selection-handle-s { bottom: -3px; cursor: ns-resize; left: 50%; margin-left: -3px; } .area-selection-handle-ne { cursor: nesw-resize; right: -3px; top: -3px; } .area-selection-handle-nw { cursor: nwse-resize; left: -3px; top: -3px; } .area-selection-handle-sw { bottom: -3px; cursor: nesw-resize; left: -3px; } .area-selection-handle-se { bottom: -3px; cursor: nwse-resize; height: 20px; opacity: 1; right: -3px; width: 20px; } .area-selection-handle-se::before { background-color: #39f; bottom: -50%; content: ' '; display: block; height: 200%; opacity: 0; position: absolute; right: -50%; width: 200%; } @media (min-width: 768px) { .area-selection-handle-se { height: 15px; width: 15px; } } @media (min-width: 992px) { .area-selection-handle-se { height: 10px; width: 10px; } } @media (min-width: 1200px) { .area-selection-handle-se { height: 5px; opacity: 0.75; width: 5px; } } .area-selection-dashed { border: 0 dashed #eee; display: block; opacity: 0.5; position: absolute; } .area-selection-dashed-h { border-bottom-width: 1px; border-top-width: 1px; height: calc(100% / 3); left: 0; top: calc(100% / 3); width: 100%; } .area-selection-dashed-v { border-left-width: 1px; border-right-width: 1px; height: 100%; left: calc(100% / 3); top: 0; width: calc(100% / 3); } .area-selection-center { display: block; height: 0; left: 50%; opacity: 0.75; position: absolute; top: 50%; width: 0; } .area-selection-center::before, .area-selection-center::after { background-color: #eee; content: ' '; display: block; position: absolute; } .area-selection-center::before { height: 1px; left: -3px; top: 0; width: 7px; } .area-selection-center::after { height: 7px; left: 0; top: -3px; width: 1px; }