Skip to content

Commit

Permalink
Merge pull request #13 from SengitU/master
Browse files Browse the repository at this point in the history
Improved modal drag performance
  • Loading branch information
bcinarli authored Jan 24, 2017
2 parents 2986324 + 9b4bd54 commit 1c75f78
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 43 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uxrocket.modal",
"version": "1.6.1",
"version": "1.6.2",
"homepage": "https://github.com/uxrocket/uxrocket.modal",
"authors": [
"Bilal Çınarlı <[email protected]>"
Expand Down
25 changes: 5 additions & 20 deletions dist/uxrocket.modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
z-index: 10000;
top: 50%;
left: 50%;
-webkit-transform: translateY(-50%) translateX(-50%);
-ms-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
-ms-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
min-width: 50px;
min-height: 50px;
padding: 20px;
Expand Down Expand Up @@ -79,8 +78,7 @@
border: 2px dashed #777;
border-radius: 50%;
box-sizing: border-box;
-webkit-animation: uxr-modal-loading 2s infinite linear;
animation: uxr-modal-loading 2s infinite linear;
animation: uxr-modal-loading 2s infinite linear;
}

.uxr-modal-close {
Expand Down Expand Up @@ -108,24 +106,11 @@
display: none;
}

@-webkit-keyframes uxr-modal-loading {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@keyframes uxr-modal-loading {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
transform: rotate(360deg);
}
}
21 changes: 15 additions & 6 deletions dist/uxrocket.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
};

Modal.prototype.bindUIActions = function() {
var _this = this;
var _this = this,
dragTimer;

this.$el
.on(events.click, function(e) {
Expand Down Expand Up @@ -193,7 +194,12 @@

$(document)
.on(events.mousemove + ' ' + events.touchmove, function(e) {
modal.move.drag(e);
if (dragTimer) {
clearTimeout(dragTimer);
}
dragTimer = setTimeout(function() {
modal.move.drag(e);
}, 100);
}).on(events.mouseup + ' ' + events.touchend, function() {
modal.move.stop();
});
Expand Down Expand Up @@ -355,6 +361,8 @@
.find('.' + utils.getClassname('close'))
.addClass(utils.getClassname('hide'));

this.$content.find('#uxr-notifications').remove();

modal.close(this);

if(this.$ph) {
Expand Down Expand Up @@ -544,10 +552,11 @@
}
},
drag: function(e) {
var pointer = this.pointer(e);
var pointer = this.pointer(e),
scrollTop = $(window).scrollTop();

if(this.selected) {
this.selected.$content[0].style.top = pointer.y + (this.selected.$content.height() / 2) + 'px';
this.selected.$content[0].style.top = pointer.y - scrollTop + (this.selected.$content.height() / 2) + 'px';
this.selected.$content[0].style.left = pointer.x + 'px';
}
},
Expand Down Expand Up @@ -620,7 +629,7 @@
return openedInstances;
};

ux.version = '1.6.1';
ux.version = '1.6.2';

ux.settings = defaults;
}));
}));
6 changes: 3 additions & 3 deletions dist/uxrocket.modal.min.css

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

6 changes: 3 additions & 3 deletions dist/uxrocket.modal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
(console'da tetiklenen callbackleri görebilirsiniz).</p>
</div>

<div class="hide" style="display: none">
<div class="hide" style="display: none">
<div id="hidden-content" class="modal-window" style="width: 480px">
<p>Sayfada normalde gizlenmiş olan bir içeriğin modal pencerede çağrılması</p>

Expand Down
4 changes: 2 additions & 2 deletions lib/_uxrocket-modal.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @author Bilal Cinarli */
$modal-version: 1.2.3;
$modal-version: 1.6.2;

/** -------------------------------------------
Modal
Expand Down Expand Up @@ -119,4 +119,4 @@ $modal-version: 1.2.3;
to {
transform: rotate(360deg);
}
}
}
21 changes: 15 additions & 6 deletions lib/uxrocket.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
};

Modal.prototype.bindUIActions = function() {
var _this = this;
var _this = this,
dragTimer;

this.$el
.on(events.click, function(e) {
Expand Down Expand Up @@ -193,7 +194,12 @@

$(document)
.on(events.mousemove + ' ' + events.touchmove, function(e) {
modal.move.drag(e);
if (dragTimer) {
clearTimeout(dragTimer);
}
dragTimer = setTimeout(function() {
modal.move.drag(e);
}, 100);
}).on(events.mouseup + ' ' + events.touchend, function() {
modal.move.stop();
});
Expand Down Expand Up @@ -355,6 +361,8 @@
.find('.' + utils.getClassname('close'))
.addClass(utils.getClassname('hide'));

this.$content.find('#uxr-notifications').remove();

modal.close(this);

if(this.$ph) {
Expand Down Expand Up @@ -544,10 +552,11 @@
}
},
drag: function(e) {
var pointer = this.pointer(e);
var pointer = this.pointer(e),
scrollTop = $(window).scrollTop();

if(this.selected) {
this.selected.$content[0].style.top = pointer.y + (this.selected.$content.height() / 2) + 'px';
this.selected.$content[0].style.top = pointer.y - scrollTop + (this.selected.$content.height() / 2) + 'px';
this.selected.$content[0].style.left = pointer.x + 'px';
}
},
Expand Down Expand Up @@ -620,7 +629,7 @@
return openedInstances;
};

ux.version = '1.6.1';
ux.version = '1.6.2';

ux.settings = defaults;
}));
}));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uxrocket.modal",
"version": "1.6.1",
"version": "1.6.2",
"description": "Modal Plugin",
"repository": {
"type": "git",
Expand Down

0 comments on commit 1c75f78

Please sign in to comment.