Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng-openseadragon dependency fix #217

Merged
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 .wvr/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const config = {
'./node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
'./node_modules/ng-table/bundles/ng-table.js',
'./node_modules/openseadragon/build/openseadragon/openseadragon.js',
'./node_modules/ng-openseadragon/build/angular-openseadragon.js',
'./src/main/webapp/app/resources/scripts/ng-openseadragon/build/angular-openseadragon.js',
'./node_modules/@wvr/core/app/config/coreConfig.js',
'./node_modules/@wvr/core/app/components/version/version.js',
'./node_modules/@wvr/core/app/components/version/version-directive.js',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"dependencies": {
"@wvr/core": "2.2.2-rc.14",
"ng-csv": "0.3.6",
"ng-openseadragon": "1.3.5",
"ng-table": "3.0.1",
"openseadragon": "2.4.0"
},
Expand Down
21 changes: 21 additions & 0 deletions src/main/webapp/app/resources/scripts/ng-openseadragon/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Damien DALY

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
"use strict";
(function () {
var module = angular.module("ui.openseadragon", []);
module.directive("seadragon", ['$timeout', function ($timeout) {
return {
restrict: "E",
scope: {
options: "=",
name: "=",
tilesource: "=",
prefixUrl: "="
},
controller: ["$scope", function ($scope) {
$scope.osd = null;
}],
link: function (scope, element, attrs) {



if (attrs.tilesource) {
opts.tileSources = [attrs.tilesource];
}
if (attrs.prefixUrl) {
opts.prefixUrl = attrs.prefixUrl;
}

function _bootstrap() {
if (scope.osd) {
scope.osd.destroy();
scope.osd = null;
}
//Create options object
var opts = angular.extend({}, scope.options, {
id: "openseadragon-" + Math.random(),
element: element[0],
});
//Create the viewer
scope.osd = OpenSeadragon(opts);
//Create a wrapper
var wrapper = {
mouse: {
position: null,
imageCoord: null,
viewportCoord: null,
},
zoom: 0,
viewport: {}
}

for(var key in scope.osd) {
wrapper[key] = scope.osd[key];
}

if (attrs.name) {
//Make the OSD available to parent scope
scope.$parent[attrs.name] = wrapper;
//Define event handlers
zoomHandler = function (e) {
$timeout(function() {
scope.$apply(function () {
wrapper.zoom = e.zoom;
});
},0);
}
updateViewportHandler = function (e) {
scope.$apply(function () {
wrapper.viewportInfo = {
bounds: scope.osd.viewport.getBounds(false),
center: scope.osd.viewport.getCenter(false),
rotation: scope.osd.viewport.getRotation(),
zoom: scope.osd.viewport.getZoom(false),
};
});
}

//Assign event handlers
scope.osd.addHandler("zoom", zoomHandler);
scope.osd.addHandler("update-viewport", updateViewportHandler);

//Add a mouse handler
scope.mouse = new OpenSeadragon.MouseTracker({
element: scope.osd.canvas,
enterHandler: function (e) {
if (scope.osd.viewport) {
var coord = OpenSeadragon.getElementPosition(scope.osd.canvas);
var pos = e.position.plus(coord);
var mouse = {
position: pos,
imageCoord: scope.osd.viewport.windowToImageCoordinates(pos),
viewportCoord: scope.osd.viewport.windowToViewportCoordinates(pos),
}
scope.$apply(function () {
wrapper.mouse = mouse;
});
}
},
moveHandler: function (e) {
if (scope.osd.viewport) {
var coord = OpenSeadragon.getElementPosition(scope.osd.canvas);
var pos = e.position.plus(coord);
var mouse = {
position: pos,
imageCoord: scope.osd.viewport.windowToImageCoordinates(pos),
viewportCoord: scope.osd.viewport.windowToViewportCoordinates(pos),
}
scope.$apply(function () {
wrapper.mouse = mouse;
});
}
},
exitHandler: function (e) {
scope.$apply(function () {
wrapper.mouse.position = null;
wrapper.mouse.imageCoord = null;
wrapper.mouse.viewportCoord = null;
});
},
});
scope.mouse.setTracking(true);
}

}
_bootstrap();
var optionsWatcher = scope.$watch('options', _bootstrap);

//if @name is set, put the wrapper in the scope and handle the events
var zoomHandler = null;
var updateViewportHandler = null;


//When element is destroyed, destroy the viewer
element.on('$destroy', function () {
//if @nam eis set, remove it from parent scope, and remove event handlers
if (attrs.name) {
//Remove from parent scope
scope.$parent[attrs.name] = null;

//Destroy mouse handler
scope.mouse.destroy();
optionsWatcher();
//Remove event handlers
scope.osd.removeHandler("zoom", zoomHandler);
scope.osd.removeHandler("update-viewport", updateViewportHandler);
}

//Destroy the viewer
scope.osd.destroy();
});
},
};
}]);
})();

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

Loading