Skip to content

Commit

Permalink
Fix closing on mobile devices when draggable
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanWagner committed Mar 2, 2021
1 parent ab12b83 commit 25d0f36
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
6 changes: 3 additions & 3 deletions demo/es6/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/es6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "ISC",
"main": "index.js",
"dependencies": {
"jbox": "^1.2.11"
"jbox": "^1.2.12"
},
"devDependencies": {
"snowpack": "^3.0.11"
Expand Down
6 changes: 5 additions & 1 deletion dist/jBox.all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jBox.all.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/jBox.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jBox.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jbox",
"version": "1.2.12",
"version": "1.2.13",
"description": "jBox is a jQuery plugin that makes it easy to create customizable tooltips, modal windows, image galleries and more.",
"keywords": [
"jquery-plugin",
Expand Down
6 changes: 5 additions & 1 deletion src/js/jBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ function jBoxWrapper(jQuery) {
handle.addClass('jBox-draggable').data('jBox-draggable', true).on('touchstart mousedown', function (ev)
{
if (ev.button == 2 || jQuery(ev.target).hasClass('jBox-noDrag') || jQuery(ev.target).parents('.jBox-noDrag').length) {
// Hacky fix for jBox not closing on mobile devices when using draggable
if (ev.type == 'touchstart' && (jQuery(ev.target).hasClass('jBox-closeButton') || jQuery(ev.target).parents('.jBox-closeButton').length)) {
this.close({ignoreDelay: true});
}
return;
}

Expand Down Expand Up @@ -483,7 +487,7 @@ function jBoxWrapper(jQuery) {
if (this.options.closeButton) {
var closeButtonSVG = this._createSVG('svg', [['viewBox', '0 0 24 24']]);
closeButtonSVG.appendChild(this._createSVG('path', [['d', 'M22.2,4c0,0,0.5,0.6,0,1.1l-6.8,6.8l6.9,6.9c0.5,0.5,0,1.1,0,1.1L20,22.3c0,0-0.6,0.5-1.1,0L12,15.4l-6.9,6.9c-0.5,0.5-1.1,0-1.1,0L1.7,20c0,0-0.5-0.6,0-1.1L8.6,12L1.7,5.1C1.2,4.6,1.7,4,1.7,4L4,1.7c0,0,0.6-0.5,1.1,0L12,8.5l6.8-6.8c0.5-0.5,1.1,0,1.1,0L22.2,4z']]));
this.closeButton = jQuery('<div class="jBox-closeButton jBox-noDrag"/>').on('click tap', function (ev) { this.close({ignoreDelay: true}); ev.stopPropagation(); }.bind(this)).append(closeButtonSVG);
this.closeButton = jQuery('<div class="jBox-closeButton jBox-noDrag"/>').on('click tap', function (ev) { this.close({ignoreDelay: true}); }.bind(this)).append(closeButtonSVG);

// Add close button to jBox container
if (this.options.closeButton == 'box' || (this.options.closeButton === true && !this.options.overlay && !this.options.title && !this.options.getTitle)) {
Expand Down

0 comments on commit 25d0f36

Please sign in to comment.