Trigger events when resizing starts

This commit is contained in:
JC Brand 2019-07-25 06:46:05 +02:00
parent 45e19acfb1
commit 2546622da3
3 changed files with 31 additions and 6 deletions

View File

@ -251,7 +251,7 @@ converse.plugins.add('converse-dragresize', {
}
},
onStartVerticalResize (ev) {
onStartVerticalResize (ev, trigger=true) {
if (!_converse.allow_dragresize) { return true; }
// Record element attributes for mouseMove().
const flyout = this.el.querySelector('.box-flyout'),
@ -262,9 +262,17 @@ converse.plugins.add('converse-dragresize', {
'direction': 'top'
};
this.prev_pageY = ev.pageY;
if (trigger) {
/**
* Triggered once the user starts to vertically resize a {@link _converse.ChatBoxView}
* @event _converse#startVerticalResize
* @example _converse.api.listen.on('startVerticalResize', (view) => { ... });
*/
_converse.api.trigger('startVerticalResize', this);
}
},
onStartHorizontalResize (ev) {
onStartHorizontalResize (ev, trigger=true) {
if (!_converse.allow_dragresize) { return true; }
const flyout = this.el.querySelector('.box-flyout'),
style = window.getComputedStyle(flyout);
@ -274,12 +282,27 @@ converse.plugins.add('converse-dragresize', {
'direction': 'left'
};
this.prev_pageX = ev.pageX;
if (trigger) {
/**
* Triggered once the user starts to horizontally resize a {@link _converse.ChatBoxView}
* @event _converse#startHorizontalResize
* @example _converse.api.listen.on('startHorizontalResize', (view) => { ... });
*/
_converse.api.trigger('startHorizontalResize', this);
}
},
onStartDiagonalResize (ev) {
this.onStartHorizontalResize(ev);
this.onStartVerticalResize(ev);
this.onStartHorizontalResize(ev, false);
this.onStartVerticalResize(ev, false);
_converse.resizing.direction = 'topleft';
/**
* Triggered once the user starts to diagonally resize a {@link _converse.ChatBoxView}
* @event _converse#startDiagonalResize
* @example _converse.api.listen.on('startDiagonalResize', (view) => { ... });
*/
_converse.api.trigger('startDiagonalResize', this);
},
};
Object.assign(_converse.ChatBoxView.prototype, dragResizable);

View File

@ -315,7 +315,7 @@ converse.plugins.add('converse-minimize', {
* to create space.
* @private
* @method _converse.ChatBoxViews#trimChats
* @param { [ChatBoxView|ChatRoomView|ControlBoxView|HeadlinesBoxView] } newchat
* @param { _converse.ChatBoxView|_converse.ChatRoomView|_converse.ControlBoxView|_converse.HeadlinesBoxView } [newchat]
*/
async trimChats (newchat) {
if (_converse.no_trimming || !_converse.connection.connected || _converse.view_mode !== 'overlayed') {

View File

@ -94,9 +94,11 @@ const CORE_PLUGINS = [
/**
* A private, closured object containing the private api (via {@link _converse.api})
* as well as private methods and internal data-structures.
*
* @global
* @namespace _converse
*/
// XXX: Strictly speaking _converse is not a global, but we need to set it as
// such to get JSDoc to create the correct document site strucure.
const _converse = {
'templates': {},
'promises': {}