Skip to content

Commit

Permalink
Merge f555e27 into c40c5f2
Browse files Browse the repository at this point in the history
  • Loading branch information
rtemision committed Sep 3, 2019
2 parents c40c5f2 + f555e27 commit 34f10cf
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion common.blocks/modal/_autoclosable/modal_autoclosable.js
Expand Up @@ -13,14 +13,28 @@ modules.define(
* @bem
*/
provide(Modal.declMod({ modName : 'autoclosable', modVal : true }, /** @lends modal.prototype */{
beforeSetMod : {
'visible' : {
'' : function() {
return this._pointerDownTarget === this._pointerUpTarget;
}
}
},

onSetMod : {
'visible' : {
'true' : function() {
this.__base.apply(this, arguments);

this._pointerDownTarget = null;
this._pointerUpTarget = null;

this
._nextTick(function() {
this._domEvents().on('pointerclick', this._onPointerClick);
this._domEvents()
.on('pointerdown', this._onPointerDown)
.on('pointerup', this._onPointerUp)
.on('pointerclick', this._onPointerClick);
})
._popup._events().on({ modName : 'visible', modVal : '' }, this._onPopupHide, this);
}
Expand All @@ -31,6 +45,14 @@ provide(Modal.declMod({ modName : 'autoclosable', modVal : true }, /** @lends mo
dom.contains(this._elem('content').domElem, $(e.target)) || this.delMod('visible');
},

_onPointerDown : function(e) {
this._pointerDownTarget = e.target;
},

_onPointerUp : function(e) {
this._pointerUpTarget = e.target;
},

_onPopupHide : function() {
this.delMod('visible');
}
Expand Down

0 comments on commit 34f10cf

Please sign in to comment.