1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
| <template lang="pug"> .disabled-index.drone-live-wrap .pup-drone.bf-blur .point.top .point.right .point.bottom .point.left .point.top-left .point.top-right .point.bottom-left .point.bottom-right
.close .pop-title 视频直播 .pop-main </template> <script> export default { name: 'video-dialog', data() { return { // 页面对象 pageObj: null, // 缩放元素 zoomBox: null, // 是否允许缩放 resizeable: false, // 鼠标按下时的坐标,并在修改尺寸时保存上一个鼠标的位置 clientX: 0, clientY: 0, // div可修改的最小宽高 minW: 8, minH: 8, // 鼠标按下时的位置,使用n、s、w、e表示 direc: '', // 页面位置 top: 160, left: 800 } }, mounted() {
// 需要调整尺寸的div this.zoomBox = this.$el.querySelector('.pup-drone') // 鼠标按下事件 this.zoomBox.onmousedown = this.zoomDown this.pageObj = document.querySelector('#app') // 页面监听移动事件 this.pageObj.onmousemove = this.zoomMove // 鼠标松开事件 this.pageObj.onmouseup = this.zoomUp }, methods: { // 鼠标按下 zoomDown(e) { // 去除鼠标默认事件 document.oncontextmenu = function(e) { e.preventDefault() } // 阻止冒泡 e.stopPropagation() let oEvent = e || event let d = this.getDirection(oEvent) // 当位置为四个边和四个角时才开启尺寸修改 if (d !== '') { this.resizeable = true this.direc = d this.clientX = e.clientX this.clientY = e.clientY } // 获取页面位置 let box = window.getComputedStyle(this.$el) let left = parseInt(box.left) this.left = left let top = parseInt(box.top) this.top = top }, // 缩放移动 zoomMove(e) { // 当开启尺寸修改时,鼠标移动会修改div尺寸 if (this.resizeable) { // 鼠标按下的位置在右边,修改宽度 if (this.direc.indexOf('e') !== -1) { this.zoomBox.style.width = Math.max(this.minW, this.zoomBox.offsetWidth + (e.clientX - this.clientX)) + 'px' this.clientX = e.clientX } // 鼠标按下的位置在上部,修改高度 if (this.direc.indexOf('n') !== -1) { let offsetHeight = this.clientY - e.clientY this.zoomBox.style.height = Math.max(this.minH, this.zoomBox.offsetHeight + offsetHeight) + 'px' this.clientY = e.clientY // 修改位置 this.top -= offsetHeight this.$el.style.top = this.top + 'px' } // 鼠标按下的位置在底部,修改高度 if (this.direc.indexOf('s') !== -1) { this.zoomBox.style.height = Math.max(this.minH, this.zoomBox.offsetHeight + (e.clientY - this.clientY)) + 'px' this.clientY = e.clientY }
// 鼠标按下的位置在左边,修改宽度,和左侧位置 if (this.direc.indexOf('w') !== -1) { let offsetWidth = this.clientX - e.clientX this.zoomBox.style.width = Math.max(this.minW, this.zoomBox.offsetWidth + offsetWidth) + 'px' this.clientX = e.clientX // 修改位置 this.left -= offsetWidth this.$el.style.left = this.left + 'px' } } }, // 鼠标抬起 zoomUp() { this.resizeable = false }, // 获取鼠标所在div的位置 getDirection(ev) { let dir = '' if (ev.target.className.indexOf('top') >= 0) { dir += 'n' } else if (ev.target.className.indexOf('bottom') >= 0) { dir += 's' } if (ev.target.className.indexOf('left') >= 0) { dir += 'w' } else if (ev.target.className.indexOf('right') >= 0) { dir += 'e' } if (ev.target.className.indexOf('item') >= 0) { dir = 'move' } return dir } }, // 卸载 beforeDestroy() {} } </script>
<style scoped lang="stylus"> .disabled-index position absolute top 160px left 800px z-index 999998
-moz-user-select none /*火狐*/ -webkit-user-select none/*webkit浏览器*/ -ms-user-select none /*IE10*/ -khtml-user-select none /*早期浏览器*/ user-select none
.pup-drone width 900px height 609px border 1px solid #00d7fe border-radius 12px position relative background rgba(4, 26, 34, 0.9) padding 0 32px 32px 32px display flex flex-direction column .close width 20px height 20px position absolute right 20px top 16px cursor pointer &::before content '' width 20px height 20px position absolute background url('~@assets/images/close.png') background-repeat no-repeat background-size 20px 20px .pop-title height 52px line-height 52px font-size 24px font-weight 700 cursor pointer .pop-main flex 1 position relative display flex font-size 18px overflow hidden background url('./assets/img/realtime.png') background-size 100% 100%
.point width 15px height 15px border-radius 2px position absolute z-index 1 cursor pointer .top top -5px width 100% cursor n-resize .bottom bottom -5px width 100% cursor s-resize .left left -5px height 100% cursor w-resize .right right -5px height 100% cursor e-resize .top-left top -5px left -5px width 30px height 30px z-index 3 cursor nw-resize .bottom-left bottom -5px left -5px width 30px height 30px z-index 3 cursor sw-resize .top-right top -5px right -5px width 30px height 30px z-index 3 cursor ne-resize .bottom-right bottom -5px right -5px width 30px height 30px z-index 3 cursor se-resize </style>
|