Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Fix image tool bugs #186

Merged
merged 2 commits into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/modules/transcribe/annotations/draggable.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function draggable($rootScope, AnnotationsFactory, MarkingSurfaceFactory) {

// function startDrag(hammerEvent) {
// // $rootScope.$broadcast('markingTools:disable');
// markingSurfaceWasEnabled = MarkingSurfaceFactory.isEnabled;
// markingSurfaceWasEnabled = MarkingSurfaceFactory.isEnabled();
// if (markingSurfaceWasEnabled) {
// MarkingSurfaceFactory.disable();
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function MarkingSurfaceFactory(MarkingSurfaceConstants) {
var _extendedFactory;
var _svgPanZoom;
var _svgRotateElement;
var _isEnabled;

factory = {
$init: init
Expand All @@ -22,7 +23,7 @@ function MarkingSurfaceFactory(MarkingSurfaceConstants) {
_extendedFactory = {
disable: disable,
enable: enable,
isEnabled: true,
isEnabled: isEnabled,
getPoint: getPoint,
resizeAndCentre: resizeAndCentre,
rotate: rotate,
Expand All @@ -33,13 +34,13 @@ function MarkingSurfaceFactory(MarkingSurfaceConstants) {
return factory;

function disable() {
factory.isEnabled = false;
_isEnabled = false;
_svgPanZoom.disablePan();
_svgPanZoom.disableZoom();
}

function enable() {
factory.isEnabled = true;
_isEnabled = true;
_svgPanZoom.enablePan();
_svgPanZoom.enableZoom();
}
Expand Down Expand Up @@ -70,6 +71,10 @@ function MarkingSurfaceFactory(MarkingSurfaceConstants) {
return _.extend(factory, _extendedFactory, { svg: svgElement });
}

function isEnabled() {
return _isEnabled;
}

function rotate(theta) {
var centre;
var rotateTransform;
Expand Down
17 changes: 11 additions & 6 deletions app/modules/transcribe/marking-tools/image.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ function imageTool($rootScope, $timeout, AnnotationsFactory, MarkingSurfaceFacto
.appendTo(MarkingSurfaceFactory.svg.find('.image-annotations'));
}

_hammer.get('pan').set({ direction: Hammer.DIRECTION_ALL });
_hammer.get('pan').set({
direction: Hammer.DIRECTION_ALL,
threshold: 0
});
_hammer.on('panstart', _startRect);
_enabled = true;

_enable();
MarkingSurfaceFactory.disable();
}

Expand Down Expand Up @@ -70,7 +74,9 @@ function imageTool($rootScope, $timeout, AnnotationsFactory, MarkingSurfaceFacto
}

function _disable() {
_enabled = false;
$timeout(function () {
_enabled = false;
});
}

function _drawRect(event) {
Expand All @@ -83,10 +89,9 @@ function imageTool($rootScope, $timeout, AnnotationsFactory, MarkingSurfaceFacto
}

function _enable() {
function setEnabled() {
$timeout(function () {
_enabled = true;
}
$timeout(setEnabled);
});
}

function _endRect() {
Expand Down
11 changes: 9 additions & 2 deletions app/modules/transcribe/overlay/context-menu.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ function contextMenu(hotkeys) {
function contextMenuController($rootScope, $scope, $timeout, MarkingSurfaceFactory) {

// Setup
var reactivateMarkingSurface;
var vm = this;
vm.close = closeMenu;
vm.open = openMenu;


// Methods
function closeMenu() {
$rootScope.$broadcast('markingTools:enable');
MarkingSurfaceFactory.enable();
if (reactivateMarkingSurface === true) {
MarkingSurfaceFactory.enable();
}
vm.active = false;
// Might be called by the event or the hotkey, so need to optionally run a digest
$timeout(function () {
Expand All @@ -79,7 +83,10 @@ function contextMenuController($rootScope, $scope, $timeout, MarkingSurfaceFacto

function openMenu(data) {
$rootScope.$broadcast('markingTools:disable');
MarkingSurfaceFactory.disable();
reactivateMarkingSurface = (MarkingSurfaceFactory.isEnabled()) ? true : false;
if (MarkingSurfaceFactory.isEnabled()) {
MarkingSurfaceFactory.disable();
}
_positionMenu(data);
vm.active = true;
vm.menuOptions = data.menuOptions;
Expand Down