OHIF-15 Fixed cine dialog positioning + dragging whole dialog even when clicking on a button.

This commit is contained in:
Emanuel Oliveira committed 2016-10-27 01:33:48 -02:00
1 parent ca28f5dbce
commit 5aaa5b934d
6 files changed
+142 -10

No files matched your search

@@ -29,6 +29,7 @@ class Bounded {
this.element = element;
this.$element = $(element);
this.options(options);
this.setBoundedFlag(false);
}
// Set or change the instance options
@@ -114,20 +115,26 @@ class Bounded {
if (this.allowResizing && elementInfo.width > boundingInfo.width) {
this.$element.width(boundingInfo.width);
this.$element.css('left', boundingInfo.x0);
this.setBoundedFlag(true);
} else if (elementInfo.x0 < boundingInfo.x0) {
this.$element.css('left', boundingInfo.x0);
this.setBoundedFlag(true);
} else if (elementInfo.x1 > boundingInfo.x1) {
this.$element.css('left', boundingInfo.x1 - elementInfo.width);
this.setBoundedFlag(true);
}
// Fix element's y positioning and height
if (this.allowResizing && elementInfo.height > boundingInfo.height) {
this.$element.height(boundingInfo.height);
this.$element.css('top', boundingInfo.y0);
this.setBoundedFlag(true);
} else if (elementInfo.y0 < boundingInfo.y0) {
this.$element.css('top', boundingInfo.y0);
this.setBoundedFlag(true);
} else if (elementInfo.y1 > boundingInfo.y1) {
this.$element.css('top', boundingInfo.y1 - elementInfo.height);
this.setBoundedFlag(true);
}
};
}
@@ -144,6 +151,11 @@ class Bounded {
this.$boundingElement.off('resize', this.spatialChangedHandler);
}
// This is a means to let outside world know that the element in question has been moved
setBoundedFlag(value) {
this.$element.data('wasBounded', value);
}
}
OHIF.Bounded = Bounded;
@@ -1,6 +1,6 @@
// Allow attaching to jQuery selectors
$.fn.draggable = function() {
makeDraggable(this);
$.fn.draggable = function(options) {
makeDraggable(this, options);
return this;
};
@@ -11,10 +11,17 @@ $.fn.draggable = function() {
*
* @param element
*/
makeDraggable = function(element) {
makeDraggable = function(element, options) {
var container = $(window);
var diffX,
diffY;
diffY,
wasNotDragged = true;
options = options || {};
options.defaultElementCursor = options.defaultElementCursor || 'default';
// initialize dragged flag
element.data('wasDragged', false);
function getCursorCoords(e) {
var cursor = {
@@ -62,11 +69,18 @@ makeDraggable = function(element) {
$(document).on('touchmove', moveHandler);
$(document).on('touchend', stopMoving);
// let outside world know that the element in question has been dragged
if (wasNotDragged) {
element.data('wasDragged', true);
wasNotDragged = false;
}
}
function stopMoving() {
container.css('cursor', 'default');
element.css('cursor', 'default');
element.css('cursor', options.defaultElementCursor);
$(document).off('mousemove', moveHandler);
$(document).off('touchmove', moveHandler);