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
'use strict';
/**
* @function add
* @param {Window} window
* @param {Document} document
* @param {String} sourceQuery
* @param {String} targetQuery
* @param {String} type
*/
export function _add(window, document, sourceQuery, targetQuery, type) {
var source = document.querySelector(sourceQuery);
var target = document.querySelector(targetQuery);
source.addEventListener('mousedown', initialiseResize, false);
function initialiseResize(e) {
window.addEventListener('mousemove', startResizing, false);
window.addEventListener('mouseup', stopResizing, false);
}
function startResizing(e) {
var height = e.clientY - target.offsetTop
var width = e.clientX - target.offsetLeft
if (type === 'both' || type === 'horizontal')
target.style.height = height + 'px';
if (type === 'both' || type === 'vertical')
target.style.width = width + 'px';
// prevent "user-select" highlights
document.body.classList.add('no-user-select');
// prevent event focus losing (eg. while hovering iframe, see #422)
document.body.classList.add('no-pointer-events');
}
function stopResizing(e) {
window.removeEventListener('mousemove', startResizing, false);
window.removeEventListener('mouseup', stopResizing, false);
document.body.classList.remove('no-user-select');
document.body.classList.remove('no-pointer-events');
}
}
/**
* @function remove
* @param {Document} document
* @param {String} sourceQuery
*/
export function _remove(document, sourceQuery) {
var source = document.querySelector(sourceQuery);
console.log(sourceQuery)
source.removeEventListener('mousedown');
}