Compare commits

...

135 Commits

Author SHA1 Message Date
Mark Salsbery
b4bb3a4afd Merge branch 'master' into ms-reference-strip 2023-08-10 15:20:31 -07:00
Ian Gilman
17cd6b51ce Changelog for #2387 and tweaks to its demo page 2023-08-08 09:39:45 -07:00
Ian Gilman
cca81a37d5
Merge pull request #2387 from schuefflerlab/BestTiles
Introduced option maxTilesPerFrame
2023-08-08 09:25:17 -07:00
Peter
0bdd807d9d Cleaned code according to comments in PR 2023-08-08 11:05:33 +02:00
Peter
f8ad0acfa4 Sort the N tiles only once instead of when adding new indiviual tiles 2023-08-02 21:04:43 +02:00
Peter
55a05963a2 Sort N tiles always for a better look and feel. 2023-08-02 20:30:30 +02:00
Ian Gilman
4a3fc5b325
Merge pull request #2389 from openseadragon/ms-mousetracker-docs
MouseTracker options docs fixes
2023-08-01 09:33:12 -07:00
Mark Salsbery
fa8196ef4f changelog update 2023-07-31 13:16:36 -07:00
Mark Salsbery
1f47f5def1 MouseTracker options docs fixes 2023-07-31 13:08:07 -07:00
Peter
13955b0bf6 added demo with maxTilesPerFrame = 3 2023-07-31 10:14:27 +02:00
Peter
17873001b8 outsourced tile sorting from tile comparing. 2023-07-28 13:15:47 +02:00
Peter
ccb4ae9f86 Fixed _updateViewport to come to a fullyLoaded state with n tiles.
Improved _compareTiles
2023-07-20 17:27:49 +02:00
Peter
9684a83b8c Updated Comment 2023-07-20 15:17:02 +02:00
P. Schueffler
7ad748799e
Pr for upstream (#3)
Added maxTilesPerFrame
2023-07-20 14:45:15 +02:00
Ian Gilman
f50df84287
Merge pull request #2386 from openseadragon/dependabot/npm_and_yarn/word-wrap-1.2.4
Bump word-wrap from 1.2.3 to 1.2.4
2023-07-18 14:00:49 -07:00
dependabot[bot]
9f31919dc1
Bump word-wrap from 1.2.3 to 1.2.4
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-18 20:28:16 +00:00
Ian Gilman
e51053a6a3 Changelog for #2382 2023-07-17 14:03:59 -07:00
Ian Gilman
eec052f054
Merge pull request #2382 from AndrewADev/update-grunt-contrib-qunit
Update grunt-contrib-qunit and extend FullScreen test
2023-07-17 14:02:02 -07:00
Andrew Armbruster
be4d5ad7f7 Update grunt-contrib-qunit and extend FullScreen test
Update the package responsible for running tests, grunt-contrib-qunit.

The package change includes a significant bump to the puppeteer version used to run the tests (from v9 -> v19: https://github.com/gruntjs/grunt-contrib-qunit#release-history).

Running the tests with the newer puppeteer version leads to issues running the FullScreen test when run in the 'old'/current default headless mode (the test fails with a timeout).

Updating to the 'new' headless mode (eventually to be the default anyway), seems to allow the fullscreen request to succeed.

Thus, go ahead and extend the FullScreen test to verify the correct values for a successful request, as well as an additional step to exit fullscreen mode.
2023-07-16 13:10:56 +02:00
Ian Gilman
ffbd8f985a Changelog for #2367 2023-06-21 14:19:06 -07:00
Ian Gilman
88f419330e Merge branch 'master' of github.com:openseadragon/openseadragon 2023-06-21 14:17:06 -07:00
Ian Gilman
3386a73e44
Merge pull request #2367 from akansjain/master
Removed createCallback function
2023-06-21 14:10:28 -07:00
akansjain
eaa41f7f05 Replaced the comment with Deprecated 2023-06-21 13:34:58 +05:30
akansjain
7dec7b9aba Added console.error() in createCallback() function 2023-06-09 17:58:22 +05:30
akansjain
3fc156d513 Removed createCallback function 2023-06-06 23:04:04 +05:30
Ian Gilman
c9cd7352c4 Changelog for #2364 2023-06-02 14:23:11 -07:00
Ian Gilman
ebab356c20
Merge pull request #2364 from SebDelile/master
workaround tile edge smoothing maxZoom + flip
2023-06-02 14:18:54 -07:00
Delile Sebastien
f96db3cf0f complete comment 2023-06-02 18:59:22 +02:00
Delile Sebastien
f004ecf323 fix comment 2023-06-01 10:20:14 +02:00
Delile Sebastien
2c03c1bbe9 workaround tile edge smoothing maxZoom + flip 2023-05-31 16:11:42 +02:00
Ian Gilman
b405a904a6
Merge pull request #2362 from AndrewADev/update-qunit
Update to most recent QUnit
2023-05-30 14:31:02 -07:00
Ian Gilman
c2a1df9ae0 Changelog for #2361 2023-05-30 14:25:44 -07:00
Ian Gilman
c69950c6e4
Merge pull request #2361 from AndrewADev/allow-es6-syntax
Allow Using ES6 Syntax
2023-05-30 14:24:34 -07:00
Andrew Armbruster
c7df7be7f1 Catch rejected Promise on failed fullscreen request
Add a `catch()` rejection of request for fullscreen (standard Fullscreen API implementation), as well as fullscreen exit. For now there is no actual handling, but we send a message to the internal error channel.

Motivation: The fullscreen request was causing certain tests to fail when run with newer versions of QUnit (starting in 2.5.0), which now fails tests that have unhandled Promise rejections (as we did here).

The exit case is not currently covered by tests, but works the same way (also returns a promise).

See: https://fullscreen.spec.whatwg.org/#ref-for-dom-element-requestfullscreen%E2%91%A0
2023-05-28 14:15:55 +02:00
Andrew Armbruster
ff67cf1cae Support ES6 Syntax
Bump ESLint's parser options to support ES6 syntax, which allows developers to start using a number of features associated with modern JavaScript.

Doing this now that #2286 has been marked as resolved, since IE 11 support was the last known blocker for such changes.
2023-05-28 12:41:30 +02:00
Andrew A
ad1179b9db Update to most recent QUnit
Update to most recent version of QUnit, which has been published under a new name for a while now.

Accordingly, replace the old package with the new one in both dependencies, as well as update references in test HTML files.
2023-05-27 13:16:28 +02:00
Ian Gilman
ea54427f42
Merge pull request #2359 from openseadragon/ian
Updated copyright to 2023
2023-05-25 14:53:05 -07:00
Ian Gilman
b9cb52a184 Updated copyright to 2023 2023-05-25 14:52:20 -07:00
Ian Gilman
3d57722b9f Changelog for #2300 2023-05-25 14:37:50 -07:00
Ian Gilman
ae9ad111c4
Merge pull request #2300 from AndrewADev/add-es-api-linting
Add ESLint plugin for linting browser compatibility
2023-05-25 14:35:47 -07:00
Ian Gilman
160cae7a4a Starting version 5.0.0 2023-05-25 13:58:21 -07:00
Ian Gilman
884968139d Version 4.1.0 2023-05-25 13:53:17 -07:00
Ian Gilman
324dc4ed30 Changelog for #2356 2023-05-24 14:03:14 -07:00
Ian Gilman
dedd85e184
Merge pull request #2356 from lcl45/rotating-navigator-region
Added navigator's region rotation
2023-05-24 13:59:23 -07:00
lcl45
7fb5744495 Resolved suggestions
- Avoid useless parameters _navigatorRotate since it already exists within the navigator;
- Automatically rotate the image in the demo page.
2023-05-24 08:45:15 +02:00
oro.niccolo
d897e5454f Added navigator's region rotation
When the "navigatorRotate" option is set to false, rotate the navigator's region accordigly to the image rotation.
2023-05-23 09:27:32 +02:00
Ian Gilman
01d940b938 Changelog for #2346 2023-05-19 15:04:46 -07:00
Ian Gilman
e6f2d3e07b
Merge pull request #2346 from uschmidt83/ajax-headers
Add `setAjaxHeaders` method to Viewer and TiledImage
2023-05-19 15:01:54 -07:00
Uwe Schmidt
4060dee4f9 Make updateAjaxHeaders private 2023-05-19 22:22:10 +02:00
Uwe Schmidt
e983bd8108 Add docs for updating ajax headers 2023-05-12 23:48:31 +02:00
Uwe Schmidt
857a825ed8 Fix some jsdoc typos 2023-05-12 23:37:34 +02:00
Uwe Schmidt
6fd828974d Update navigator ajax headers 2023-05-12 21:46:16 +02:00
Uwe Schmidt
e51aa4a9c5 Refine setAjaxHeaders
- Allow null to clear headers (same as empty object)
- Add TiledImage._updateAjaxHeaders
- Add error message in case of invalid headers
2023-05-05 01:13:44 +02:00
Uwe Schmidt
182c11481e Add tests for setAjaxHeaders 2023-05-05 00:03:22 +02:00
Ian Gilman
6981cfed01 Changelog for #2347 2023-05-04 13:45:06 -07:00
Ian Gilman
d4057aca12
Merge pull request #2347 from pearcetm/navigator-fix
update navigator size when calling setHeight or setWidth
2023-05-04 13:42:17 -07:00
Tom
528df37335 update navigator size when calling setHeight or setWidth 2023-05-03 22:38:49 -04:00
Uwe Schmidt
b23e8295d3 Propagate updated ajax headers by default 2023-05-03 23:51:07 +02:00
Uwe Schmidt
13603dd5f4 Update reference strip ajax headers 2023-05-03 19:33:50 +02:00
Uwe Schmidt
fe7a5eb01b Make ES5-compatible 2023-05-03 18:46:18 +02:00
Uwe Schmidt
3c2628f182 Add setAjaxHeaders method to Viewer and TiledImage
- First draft, not tested at all
- See openseadragon/openseadragon#1748
2023-05-03 16:05:58 +02:00
Ian Gilman
b1274515aa Tiny basic.html tweak 2023-04-27 14:27:40 -07:00
Ian Gilman
b088fc0da3 Changelog for #2337 2023-04-27 14:27:09 -07:00
Ian Gilman
d36c76127c
Merge pull request #2337 from ruven/master
Use resolution level dimensions provided in the info.json "sizes" field
2023-04-27 14:24:23 -07:00
Ruven
c5404006b2
Further optimization: code moved into constructor thereby eliminating need for getLevelSize() function. 2023-04-25 12:06:27 +02:00
Ruven
5fd125dc92
Added implementation of getTileAtPoint() function. This eliminates flickering at level transitions caused by mis-match in resolution size calculation between the getTileAtPoint() and getNumTiles() functions. 2023-04-24 22:44:46 +02:00
Ruven
877c3b68ed
Refactored code to take into account optimization suggestions (https://github.com/openseadragon/openseadragon/pull/2337#discussion_r1170931340) 2023-04-24 17:24:18 +02:00
Ruven
0c358c140d
Use resolution level dimensions provided in the info.json "sizes" field to determine tile sizes as well as the number of tiles that exist at a particular resolution. Fall back to calculation using ceil() if no resolution sizes provided. Avoids rounding errors for edge tiles and fixes https://github.com/openseadragon/openseadragon/issues/2321 2023-04-17 21:08:18 +02:00
Ian Gilman
60a6a610e0 Changelog for #2334 2023-04-10 14:23:31 -07:00
Ian Gilman
f91dbdd2c7
Merge pull request #2334 from Ughuuu/Fix-TileLoader-re-trying-even-if-successful
Fix TileLoader re-trying even if successful #2
2023-04-10 14:18:58 -07:00
Dragos Daian
d18a4c3fd7 mark tile.exists so that the retired tiles appear. 2023-04-08 16:48:04 +02:00
Ian Gilman
ebda5a909b Changelog for #2333 2023-04-07 13:49:12 -07:00
Ian Gilman
4f737f1714
Merge pull request #2333 from robertjcolley/master
Fixes navigator rotation not honoring immediately parameter
2023-04-07 13:47:35 -07:00
Robert Colley
e6b9c79bc1
Fixes #2332
Mirror the main viewer's rotation and account for immediately. Without 
this, viewer.setRotation(90, true) would rotate the main viewer without 
animation and the navigator with animation.
2023-04-06 18:10:38 -04:00
Ian Gilman
8b305546ed Changelog for #2324 2023-04-06 14:26:15 -07:00
Ian Gilman
5b56d6fa16
Merge pull request #2324 from rsimon/master
Applied touch rotate fix suggested in #2319
2023-04-06 14:22:54 -07:00
Ian Gilman
2e99e48603 Fixed changelog for #2136 2023-04-06 14:12:30 -07:00
Ian Gilman
b45d500f1e Changelog for #2328 2023-04-04 14:51:05 -07:00
Ian Gilman
cec0acafe1
Merge pull request #2328 from craigberry/master
Handle XML embedded in tilesource JSON
2023-04-04 14:48:52 -07:00
Ian Gilman
073b2e0b1f Changelog for #2318 2023-03-31 15:30:19 -07:00
Ian Gilman
3488d18e4c
Merge pull request #2318 from donotloveshampo/patch-1
Fixed #2314
2023-03-31 15:27:43 -07:00
Craig A. Berry
bff93af17e Handle XML embedded in tilesource JSON
The existing check for whether the tilesource data is XML or JSON
looks for a tag anywhere in the response content, which incorrectly
flags the content as XML in the case where it is really JSON with
XML embedded in it.

This commit corrects that problem by requiring the tag to occur as
the first non-whitespace part of the content. This is basically a
poor person's well-formedness check since well-formed XML cannot
have non-whitespace content outside of the root node.

N.B. While malformed XML content with non-whitespace characters
before the first element has been getting identified as XML, it
has not been getting parsed correctly.  With current parsing
infrastructure, the content has been getting replaced by a parsing
error message.  With more up-to-date parsing infrastructure, it
will throw an error.  Either way we're not losing anything by failing
to identify malformed XML as XML.

Addresses issue #2325.
2023-03-30 16:38:35 -05:00
Rainer Simon
84d2dcf11d Applied touch rotate fix suggested in #2319 2023-03-25 18:38:58 +01:00
donotloveshampo
244e54da69
Fixed #2314 2023-03-17 16:27:12 +08:00
Ian Gilman
292b62ba21 Change log for #2317 2023-03-16 13:26:59 -07:00
Ian Gilman
dec2afabb2 Merge branch 'master' of github.com:openseadragon/openseadragon 2023-03-16 13:23:40 -07:00
Ian Gilman
2ae9fb0e13
Merge pull request #2317 from pearcetm/after-resize-event
Add after-resize event
2023-03-16 13:22:50 -07:00
Ian Gilman
56ae09fc8a Changelog for #2316 2023-03-14 14:02:07 -07:00
Ian Gilman
5f816246e4
Merge pull request #2316 from pearcetm/scaled-crop-bugfix
partial bugfix for #2312
2023-03-14 13:57:35 -07:00
Tom
fb32cc7198 add after-resize event 2023-03-13 22:19:06 -04:00
Tom
a01c230b6e partial bugfix for #2312 2023-03-13 21:56:06 -04:00
Ian Gilman
bf06f271c6 Changelog for #2293 2023-03-10 13:52:32 -08:00
Ian Gilman
cbb0a009e7
Merge pull request #2293 from pearcetm/zoom-constraints-fix
Take zoom constraint into account within _fitBounds
2023-03-10 13:49:41 -08:00
Ian Gilman
25b4d7a3ca
Merge pull request #2308 from AndrewADev/set-node-lts-in-ci
Update Travis to use latest Node LTS
2023-03-07 14:27:02 -08:00
Ian Gilman
624609d800 Changelog for #2306 2023-03-06 14:25:38 -08:00
Ian Gilman
afae0ec5ec
Merge pull request #2306 from MohitBansal321/addButton
add custom button for this viewer
2023-03-06 14:22:34 -08:00
Andrew Armbruster
2764e3ad9a Try an even newer build env
This would buy even more time to find an alternative to pinning the runner version.
2023-02-28 21:16:41 +01:00
Andrew Armbruster
5c12e1ce1c Use newer runner version
Request a newer runner version from Travis CI due to a glibc version bump in newer versions of Node.
2023-02-28 21:04:22 +01:00
Andrew Armbruster
7d2ceac61a Travis uses latest Node LTS
Update CI config to use the most recent LTS.

For some other possible values, see: https://docs.travis-ci.com/user/languages/javascript-with-nodejs/#specifying-nodejs-versions
2023-02-28 20:21:10 +01:00
Mohit Bansal
8a201c12b4 add given button function to buttongroup 2023-02-28 01:05:22 +05:30
Mohit Bansal
f393547d9e add custom button 2023-02-27 23:52:29 +05:30
Andrew A
b0233f6a24 Drop non-standard lint command
Stick to existing approach leveraging grunt for dev tasks.
2023-02-24 19:51:42 +01:00
Andrew A
2932b0a800 Exclude IE 11 from query
We are ready to drop IE 11, so no need for it to be included in the browserslist

See: https://github.com/openseadragon/openseadragon/pull/2300#pullrequestreview-1308240522
2023-02-24 19:50:38 +01:00
Ian Gilman
59083b7669 Changelog for #2301 2023-02-23 15:07:09 -08:00
Ian Gilman
f0d15e3e79
Merge pull request #2301 from MohitBansal321/focusEvent
add canvas-focus and canvas-blur events to Viewer
2023-02-23 15:04:11 -08:00
Mohit Bansal
795e85bebb update doc comments 2023-02-22 10:21:51 +05:30
Mohit Bansal
c05af1d38b add focus and blur event 2023-02-19 15:49:43 +05:30
Andrew A
ab0ddcae3d Add a lint script
Make it easy to lint in stand-alone fashion.

Note that I'm going with a direct call to ESLint, as using `grunt eslint` leads to warnings about a circular dependency (per trace it seems to originate in istanbul?)
2023-02-18 15:55:03 +01:00
Andrew A
09a119afe3 Add ESLint plugin for ES API linting
Adding [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) to check for usage of incompatible APIs.

For a list of browsers, we start out using both the 'defaults' query along with IE 11, which is still expressly supported in OSD v4 (current).
2023-02-18 15:50:21 +01:00
Ian Gilman
25aabbe766
Merge pull request #2298 from MohitBansal321/npmOutdated
some npm packages outdated
2023-02-17 14:16:07 -08:00
Ian Gilman
f2fa9dbb41 Changelog for #2297 2023-02-17 14:01:56 -08:00
Ian Gilman
9026c3a71d
Merge pull request #2297 from KevinBritten/docs/button-type-fix
2087 add type Element to documentation for custom ui buttons
2023-02-17 13:57:33 -08:00
Mohit Bansal
e765860aeb Merge branch 'master' of https://github.com/openseadragon/openseadragon into npmOutdated 2023-02-17 15:26:10 +05:30
Kevin Britten
8ec6e55304
Merge branch 'openseadragon:master' into docs/button-type-fix 2023-02-16 17:21:44 -05:00
Ian Gilman
5a5420972c Changelog for #2291 2023-02-16 14:16:56 -08:00
Ian Gilman
c7992411a5
Merge pull request #2291 from MohitBansal321/keyboardHandling
Consolidate viewer keyboard handling into keydown handler
2023-02-16 14:13:45 -08:00
Kevin Britten
cf3bf91b8d add type Element to documentation for custom ui buttons 2023-02-16 14:51:30 -05:00
Mohit Bansal
8442cc2b2b update npm packages 2023-02-15 19:15:22 +05:30
Mohit Bansal
0ab81df9b8 remove unwanted property 2023-02-15 09:37:03 +05:30
Mohit Bansal
6be459e451 formatting 2023-02-13 23:13:08 +05:30
Mohit Bansal
78928e3510 add comment 2023-02-13 23:01:19 +05:30
Mohit Bansal
4909320089 correction of keyCode 2023-02-12 13:30:41 +05:30
Mohit Bansal
3a8738fd43 spacing && documentation 2023-02-12 12:43:41 +05:30
Mohit Bansal
dac697c74e formatting 2023-02-10 16:44:55 +05:30
Mohit Bansal
4bc9ea4573 add keypress handler's event 2023-02-09 12:55:44 +05:30
Mohit Bansal
cfa88b701f replace canvasKeyPressEventArgs to canvasKeyDownEventArgs 2023-02-08 19:22:27 +05:30
Tom
16fc72d8fb Take zoom constraint into account within _fitBounds when constraints = true and immediately = false 2023-02-07 18:12:26 -05:00
Mohit Bansal
f36d44dc67 Consolidate viewer keyboard handling into keydown handler 2023-02-07 03:31:57 +05:30
Ian Gilman
ead728dc35 Changelog for #2282 2023-02-03 14:07:08 -08:00
Ian Gilman
3cf3fb50b2
Merge pull request #2282 from RationAI/master
Ensure tile-loaded event completionCallback is called only once.
2023-02-03 14:03:39 -08:00
Aiosa
37d4f62ce9 Remove discouraging note on getCompletionCallback use docs. 2023-02-02 17:18:12 +01:00
Aiosa
57486732b1 Prevent early tile completion with call order instead of guard flag. Improve getCompletionCallback docs. 2023-02-01 10:25:10 +01:00
Aiosa
55e7d2439a Change completionCallback with 'tile-loaded' event to support original scenario of async completion notification with additional guarding flags. 2023-01-31 08:05:02 +01:00
Aiosa
81d86570da Typo in the stopping comparison condition. 2023-01-28 14:08:00 +01:00
Aiosa
947109718c Ensure tile-loaded event completionCallback is called only once. Check when context2D used after cache creation. 2023-01-28 08:42:07 +01:00
49 changed files with 1724 additions and 6827 deletions

1
.browserslistrc Normal file
View File

@ -0,0 +1 @@
defaults

View File

@ -1,14 +1,16 @@
{
"root": true,
"plugins": ["compat"],
"extends": [
"eslint:recommended"
"eslint:recommended",
"plugin:compat/recommended"
],
"env": {
"es6": false,
"es6": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 5,
"ecmaVersion": 6,
"sourceType": "script",
"ecmaFeatures": {
"globalReturn": false,

View File

@ -1,6 +1,10 @@
# Specify dist until Travis CI default Runner OS updates to one
# with glibc version required by newer Node versions
# See: https://github.com/nodejs/node/issues/42351#issuecomment-1068424442
dist: jammy
language: node_js
sudo: false
node_js:
- "16.14.2"
- lts/*
before_install:
- npm install -g grunt-cli

View File

@ -161,8 +161,11 @@ module.exports = function(grunt) {
normal: {
options: {
urls: [ "http://localhost:8000/test/test.html" ],
timeout: 10000
}
timeout: 10000,
puppeteer: {
headless: 'new'
}
},
},
coverage: {
options: {

View File

@ -1,5 +1,5 @@
Copyright (C) 2009 CodePlex Foundation
Copyright (C) 2010-2022 OpenSeadragon contributors
Copyright (C) 2010-2023 OpenSeadragon contributors
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

View File

@ -1,18 +1,43 @@
OPENSEADRAGON CHANGELOG
=======================
4.0.1: (in progress...)
5.0.0: (in progress...)
* The viewer no longer emits canvas-key events for both keydown and keypress events; canvas-key is now just for keydown, and the new canvas-key-press is for keypress (#2270 @hrghauri)
* BREAKING CHANGE: Dropped support for IE11 (#2300, #2361 @AndrewADev)
* DEPRECATION: The OpenSeadragon.createCallback function is no longer recommended (#2367 @akansjain)
* Introduced maxTilesPerFrame option to allow loading more tiles simultaneously (#2387 @jetic83)
* Test improvements (#2382 @AndrewADev)
* MouseTracker options documentation fixes (#2389 @msalsbery)
* Fixed: Sometimes if the viewport was flipped and the user zoomed in far enough, it would flip back (#2364 @SebDelile)
4.1.0:
* NEW BEHAVIOR: When `navigatorRotate` is false, while the navigator image doesn't rotate, the red outline now does (#2356 @lcl45)
* The viewer no longer emits `canvas-key` events for both keydown and keypress events; canvas-key is now just for keydown, and the new `canvas-key-press` is for keypress (#2270 @hrghauri)
* You can now specify a priority when calling addHandler, to control when your event handler gets called relative to others (#2273 @Aiosa)
* Added tileRetryMax and tileRetryDelay options, so the viewer can retry loading failed tiles (#2238 @Ughuuu, @paaddyy)
* Fixed: Navigator display rectangle was off if the page had box-sizing: border-box (#2276 @ambujsahu81)
* Added tileRetryMax and tileRetryDelay options, so the viewer can retry loading failed tiles (#2238 @Ughuuu @paaddyy, #2334 @Ughuuu @Titan21)
* All of the viewers keyboard handling is now in response to keydown events (it used to be split between keydown and keypress) (#2291 @MohitBansal321)
* Added `canvas-focus` and `canvas-blur` events to Viewer (#2301 @MohitBansal321)
* You can now more easily add custom buttons to the viewer (#2306 @MohitBansal321)
* The fitBounds function now takes zoom constraints into account (#2293 @pearcetm)
* The viewer now has an `after-resize` event what happens after the viewport bounds have been updated, to complement the `resize` event which happens before (#2317 @pearcetm)
* IIIFTileSource now uses resolution level dimensions provided in the info.json "sizes" field for more accurate tile requests (#2337 @ruven)
* Added setAjaxHeaders method to Viewer and TiledImage (#2346 @uschmidt83)
* Improved documentation (#2297 @KevinBritten)
* Fixed: The `tile-loaded` event's completionCallback could be called more than once in some circumstances (#2282 @Aiosa, @pearcetm)
* Fixed: Navigator display rectangle was off if the page had `box-sizing: border-box` (#2276 @ambujsahu81)
* Fixed: Code that required identifying functions would fail for async functions (#2273 @Aiosa)
* Fixed: Reference strip click detection was not accurate for long reference strips (#2280 @damonsson)
* Fixed: Translation problems in some circumstances with cropping polygons enabled (#2316 @pearcetm)
* Fixed: The navigator area rectangle would grow larger when you zoom in very far (#2318 @donotloveshampo)
* Fixed: JSON with embedded XML was being incorrectly identified as XML (#2328 @craigberry)
* Fixed: Touch/pinch rotate was not working properly on some platforms (#2324 @rsimon, @pearcetm)
* Fixed: Navigator rotation didn't honor `immediately` parameter (#2333 @robertjcolley)
* Fixed: The navigator didn't update for its new size in certain circumstances (#2347 @pearcetm)
4.0.0:
* NEW BEHAVIOR: Setting the viewport rotation now animates by default (pass false for the new `immediately` parameter to disable) (#2136 @jonasengelmann)
* NEW BEHAVIOR: Setting the viewport rotation now animates by default (pass true for the new `immediately` parameter to disable) (#2136 @jonasengelmann)
* NEW BEHAVIOR: The auto resize now takes both width and height into account when scaling the contents proportionally to the viewer (#2256 @pearcetm)
* DEPRECATION: Don't access the viewport's degrees property directly anymore; instead use setRotation and getRotation (#2136 @jonasengelmann)
* New gesture: Double-click and drag to zoom (on by default for touch) (#2225 @HamzaTatheer)

7468
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "openseadragon",
"version": "4.0.0",
"version": "4.1.0",
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
"keywords": [
"image",
@ -29,22 +29,23 @@
"url": "https://github.com/openseadragon/openseadragon.git"
},
"devDependencies": {
"grunt": "^1.4.1",
"grunt-contrib-clean": "^2.0.0",
"eslint-plugin-compat": "^4.1.2",
"grunt": "^1.6.1",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-compress": "^2.0.0",
"grunt-contrib-concat": "^2.0.0",
"grunt-contrib-concat": "^2.1.0",
"grunt-contrib-connect": "^3.0.0",
"grunt-contrib-qunit": "^6.2.0",
"grunt-contrib-qunit": "^7.0.1",
"grunt-contrib-uglify": "^5.0.1",
"grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^24.0.0",
"grunt-eslint": "^24.0.1",
"grunt-git-describe": "^2.4.4",
"grunt-istanbul": "^0.8.0",
"grunt-text-replace": "^0.4.0",
"qunitjs": "2.4.1"
"qunit": "^2.19.4"
},
"scripts": {
"test": "grunt test",
"prepare": "grunt build"
}
}
}

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Button
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - ButtonGroup
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -112,6 +112,17 @@ $.ButtonGroup = function( options ) {
/** @lends OpenSeadragon.ButtonGroup.prototype */
$.ButtonGroup.prototype = {
/**
* Adds the given button to this button group.
*
* @function
* @param {OpenSeadragon.Button} button
*/
addButton: function( button ){
this.buttons.push(button);
this.element.appendChild(button.element);
},
/**
* TODO: Figure out why this is used on the public API and if a more useful
* api can be created.

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Control
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - ControlDock
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - DisplayRect
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Drawer
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - DziTileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - EventSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - full-screen support functions
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -67,10 +67,14 @@
return document.fullscreenElement;
};
fullScreenApi.requestFullScreen = function( element ) {
return element.requestFullscreen();
return element.requestFullscreen().catch(function (msg) {
$.console.error('Fullscreen request failed: ', msg);
});
};
fullScreenApi.exitFullScreen = function() {
document.exitFullscreen();
document.exitFullscreen().catch(function (msg) {
$.console.error('Error while exiting fullscreen: ', msg);
});
};
fullScreenApi.fullScreenEventName = "fullscreenchange";
fullScreenApi.fullScreenErrorEventName = "fullscreenerror";

View File

@ -2,7 +2,7 @@
* OpenSeadragon - IIIFTileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -141,6 +141,18 @@ $.IIIFTileSource = function( options ){
}
}
// Create an array with our exact resolution sizes if these have been supplied
if( this.sizes ) {
var sizeLength = this.sizes.length;
if ( (sizeLength === options.maxLevel) || (sizeLength === options.maxLevel + 1) ) {
this.levelSizes = this.sizes;
// Need to take into account that the list may or may not include the full resolution size
if( sizeLength === options.maxLevel ) {
this.levelSizes.push( {width: this.width, height: this.height} );
}
}
}
$.TileSource.apply( this, [ options ] );
};
@ -333,7 +345,17 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
}
}
return $.TileSource.prototype.getNumTiles.call(this, level);
// Use supplied list of scaled resolution sizes if these exist
if( this.levelSizes ) {
var levelSize = this.levelSizes[level];
var x = Math.ceil( levelSize.width / this.getTileWidth(level) ),
y = Math.ceil( levelSize.height / this.getTileHeight(level) );
return new $.Point( x, y );
}
// Otherwise call default TileSource->getNumTiles() function
else {
return $.TileSource.prototype.getNumTiles.call(this, level);
}
},
@ -348,6 +370,34 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
return new $.Point(0, 0);
}
// Use supplied list of scaled resolution sizes if these exist
if( this.levelSizes ) {
var validPoint = point.x >= 0 && point.x <= 1 &&
point.y >= 0 && point.y <= 1 / this.aspectRatio;
$.console.assert(validPoint, "[TileSource.getTileAtPoint] must be called with a valid point.");
var widthScaled = this.levelSizes[level].width;
var pixelX = point.x * widthScaled;
var pixelY = point.y * widthScaled;
var x = Math.floor(pixelX / this.getTileWidth(level));
var y = Math.floor(pixelY / this.getTileHeight(level));
// When point.x == 1 or point.y == 1 / this.aspectRatio we want to
// return the last tile of the row/column
if (point.x >= 1) {
x = this.getNumTiles(level).x - 1;
}
var EPSILON = 1e-15;
if (point.y >= 1 / this.aspectRatio - EPSILON) {
y = this.getNumTiles(level).y - 1;
}
return new $.Point(x, y);
}
// Otherwise call default TileSource->getTileAtPoint() function
return $.TileSource.prototype.getTileAtPoint.call(this, level, point);
},
@ -375,10 +425,9 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
var IIIF_ROTATION = '0',
//## get the scale (level as a decimal)
scale = Math.pow( 0.5, this.maxLevel - level ),
//# image dimensions at this level
levelWidth = Math.round( this.width * scale ),
levelHeight = Math.round( this.height * scale ),
levelWidth,
levelHeight,
//## iiif region
tileWidth,
@ -396,6 +445,17 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
iiifQuality,
uri;
// Use supplied list of scaled resolution sizes if these exist
if( this.levelSizes ) {
levelWidth = this.levelSizes[level].width;
levelHeight = this.levelSizes[level].height;
}
// Otherwise calculate the sizes ourselves
else {
levelWidth = Math.ceil( this.width * scale );
levelHeight = Math.ceil( this.height * scale );
}
tileWidth = this.getTileWidth(level);
tileHeight = this.getTileHeight(level);
iiifTileSizeWidth = Math.round( tileWidth / scale );
@ -426,8 +486,8 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
} else {
iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
}
iiifSizeW = Math.round( iiifTileW * scale );
iiifSizeH = Math.round( iiifTileH * scale );
iiifSizeW = Math.min( tileWidth, levelWidth - (x * tileWidth) );
iiifSizeH = Math.min( tileHeight, levelHeight - (y * tileHeight) );
if ( this.version === 2 && iiifSizeW === this.width ) {
iiifSize = "full";
} else if ( this.version === 3 && iiifSizeW === this.width && iiifSizeH === this.height ) {

View File

@ -2,7 +2,7 @@
* OpenSeadragon - ImageLoader
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -62,7 +62,7 @@ $.ImageJob = function(options) {
/**
* Data object which will contain downloaded image data.
* @member {Image|*} image data object, by default an Image object (depends on TileSource)
* @member {Image|*} data data object, by default an Image object (depends on TileSource)
* @memberof OpenSeadragon.ImageJob#
*/
this.data = null;
@ -234,7 +234,7 @@ $.ImageLoader.prototype = {
* @param callback - Called once cleanup is finished.
*/
function completeJob(loader, job, callback) {
if (job.errorMsg !== '' && (job.image === null || job.image === undefined) && job.tries < 1 + loader.tileRetryMax) {
if (job.errorMsg !== '' && (job.data === null || job.data === undefined) && job.tries < 1 + loader.tileRetryMax) {
loader.failedTiles.push(job);
}
var nextJob;

View File

@ -2,7 +2,7 @@
* OpenSeadragon - ImageTileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - LegacyTileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - MouseTracker
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -57,16 +57,16 @@
* @param {Boolean} [options.startDisabled=false]
* If true, event tracking on the element will not start until
* {@link OpenSeadragon.MouseTracker.setTracking|setTracking} is called.
* @param {Number} options.clickTimeThreshold
* @param {Number} [options.clickTimeThreshold=300]
* The number of milliseconds within which a pointer down-up event combination
* will be treated as a click gesture.
* @param {Number} options.clickDistThreshold
* @param {Number} [options.clickDistThreshold=5]
* The maximum distance allowed between a pointer down event and a pointer up event
* to be treated as a click gesture.
* @param {Number} options.dblClickTimeThreshold
* @param {Number} [options.dblClickTimeThreshold=300]
* The number of milliseconds within which two pointer down-up event combinations
* will be treated as a double-click gesture.
* @param {Number} options.dblClickDistThreshold
* @param {Number} [options.dblClickDistThreshold=20]
* The maximum distance allowed between two pointer click events
* to be treated as a click gesture.
* @param {Number} [options.stopDelay=50]

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Navigator
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -224,19 +224,19 @@ $.Navigator = function( options ){
this.displayRegionContainer.appendChild(this.displayRegion);
this.element.getElementsByTagName('div')[0].appendChild(this.displayRegionContainer);
function rotate(degrees) {
function rotate(degrees, immediately) {
_setTransformRotate(_this.displayRegionContainer, degrees);
_setTransformRotate(_this.displayRegion, -degrees);
_this.viewport.setRotation(degrees);
_this.viewport.setRotation(degrees, immediately);
}
if (options.navigatorRotate) {
var degrees = options.viewer.viewport ?
options.viewer.viewport.getRotation() :
options.viewer.degrees || 0;
rotate(degrees);
rotate(degrees, true);
options.viewer.addHandler("rotate", function (args) {
rotate(args.degrees);
rotate(args.degrees, args.immediately);
});
}
@ -324,6 +324,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
this.width = width;
this.element.style.width = typeof (width) === "number" ? (width + 'px') : width;
this._resizeWithViewer = false;
this.updateSize();
},
/**
@ -334,6 +335,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
this.height = height;
this.element.style.height = typeof (height) === "number" ? (height + 'px') : height;
this._resizeWithViewer = false;
this.updateSize();
},
/**
@ -395,15 +397,20 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
bottomright = this.viewport.pixelFromPointNoRotate(bounds.getBottomRight(), false)
.minus( this.totalBorderWidths );
if (!this.navigatorRotate) {
var degrees = viewport.getRotation(true);
_setTransformRotate(this.displayRegion, -degrees);
}
//update style for navigator-box
var style = this.displayRegion.style;
style.display = this.world.getItemCount() ? 'block' : 'none';
style.top = Math.round( topleft.y ) + 'px';
style.left = Math.round( topleft.x ) + 'px';
style.top = topleft.y.toFixed(2) + "px";
style.left = topleft.x.toFixed(2) + "px";
var width = Math.abs( topleft.x - bottomright.x );
var height = Math.abs( topleft.y - bottomright.y );
var width = bottomright.x - topleft.x;
var height = bottomright.y - topleft.y;
// make sure width and height are non-negative so IE doesn't throw
style.width = Math.round( Math.max( width, 0 ) ) + 'px';
style.height = Math.round( Math.max( height, 0 ) ) + 'px';

View File

@ -2,7 +2,7 @@
* OpenSeadragon
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -60,7 +60,7 @@
/*
* Portions of this source file taken from mattsnider.com:
*
* Copyright (c) 2006-2022 Matt Snider
* Copyright (c) 2006-2013 Matt Snider
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -290,6 +290,12 @@
* @property {Number} [rotationIncrement=90]
* The number of degrees to rotate right or left when the rotate buttons or keyboard shortcuts are activated.
*
* @property {Number} [maxTilesPerFrame=1]
* The number of tiles loaded per frame. As the frame rate of the client's machine is usually high (e.g., 50 fps),
* one tile per frame should be a good choice. However, for large screens or lower frame rates, the number of
* loaded tiles per frame can be adjusted here. Reasonable values might be 2 or 3 tiles per frame.
* (Note that the actual frame rate is given by the client's browser and machine).
*
* @property {Number} [pixelsPerWheelLine=40]
* For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
*
@ -565,50 +571,50 @@
* viewing the first image and the 'next' button will wrap to the first
* image when viewing the last image.
*
* @property {String} zoomInButton
* Set the id of the custom 'Zoom in' button to use.
*@property {String|Element} zoomInButton
* Set the id or element of the custom 'Zoom in' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} zoomOutButton
* Set the id of the custom 'Zoom out' button to use.
* @property {String|Element} zoomOutButton
* Set the id or element of the custom 'Zoom out' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} homeButton
* Set the id of the custom 'Go home' button to use.
* @property {String|Element} homeButton
* Set the id or element of the custom 'Go home' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} fullPageButton
* Set the id of the custom 'Toggle full page' button to use.
* @property {String|Element} fullPageButton
* Set the id or element of the custom 'Toggle full page' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} rotateLeftButton
* Set the id of the custom 'Rotate left' button to use.
* @property {String|Element} rotateLeftButton
* Set the id or element of the custom 'Rotate left' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} rotateRightButton
* Set the id of the custom 'Rotate right' button to use.
* @property {String|Element} rotateRightButton
* Set the id or element of the custom 'Rotate right' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} previousButton
* Set the id of the custom 'Previous page' button to use.
* @property {String|Element} previousButton
* Set the id or element of the custom 'Previous page' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
*
* @property {String} nextButton
* Set the id of the custom 'Next page' button to use.
* @property {String|Element} nextButton
* Set the id or element of the custom 'Next page' button to use.
* This is useful to have a custom button anywhere in the web page.<br>
* To only change the button images, consider using
* {@link OpenSeadragon.Options.navImages}
@ -1288,6 +1294,7 @@ function OpenSeadragon( options ){
preserveImageSizeOnResize: false, // requires autoResize=true
minScrollDeltaTime: 50,
rotationIncrement: 90,
maxTilesPerFrame: 1,
//DEFAULT CONTROL SETTINGS
showSequenceControl: true, //SEQUENCE
@ -2251,25 +2258,12 @@ function OpenSeadragon( options ){
event.stopPropagation();
},
/**
* Similar to OpenSeadragon.delegate, but it does not immediately call
* the method on the object, returning a function which can be called
* repeatedly to delegate the method. It also allows additional arguments
* to be passed during construction which will be added during each
* invocation, and each invocation can add additional arguments as well.
*
* @function
* @param {Object} object
* @param {Function} method
* @param [args] any additional arguments are passed as arguments to the
* created callback
* @returns {Function}
*/
// Deprecated
createCallback: function( object, method ) {
//TODO: This pattern is painful to use and debug. It's much cleaner
// to use pinning plus anonymous functions. Get rid of this
// pattern!
console.error('The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.');
var initialArgs = [],
i;
for ( i = 2; i < arguments.length; i++ ) {

View File

@ -2,7 +2,7 @@
* OpenSeadragon - OsmTileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Overlay
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Point
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Profiler
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Rect
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - ReferenceStrip
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Spring
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - getString/setString
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Tile
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - TileCache
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - TiledImage
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -147,6 +147,9 @@ $.TiledImage = function( options ) {
var degrees = options.degrees || 0;
delete options.degrees;
var ajaxHeaders = options.ajaxHeaders;
delete options.ajaxHeaders;
$.extend( true, this, {
//internal state properties
@ -179,7 +182,8 @@ $.TiledImage = function( options ) {
opacity: $.DEFAULT_SETTINGS.opacity,
preload: $.DEFAULT_SETTINGS.preload,
compositeOperation: $.DEFAULT_SETTINGS.compositeOperation,
subPixelRoundingForTransparency: $.DEFAULT_SETTINGS.subPixelRoundingForTransparency
subPixelRoundingForTransparency: $.DEFAULT_SETTINGS.subPixelRoundingForTransparency,
maxTilesPerFrame: $.DEFAULT_SETTINGS.maxTilesPerFrame
}, options );
this._preload = this.preload;
@ -238,6 +242,9 @@ $.TiledImage = function( options ) {
tiledImage: _this
}, args));
};
this._ownAjaxHeaders = {};
this.setAjaxHeaders(ajaxHeaders, false);
};
$.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.TiledImage.prototype */{
@ -1003,6 +1010,90 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
});
},
/**
* Update headers to include when making AJAX requests.
*
* Unless `propagate` is set to false (which is likely only useful in rare circumstances),
* the updated headers are propagated to all tiles and queued image loader jobs.
*
* Note that the rules for merging headers still apply, i.e. headers returned by
* {@link OpenSeadragon.TileSource#getTileAjaxHeaders} take precedence over
* the headers here in the tiled image (`TiledImage.ajaxHeaders`).
*
* @function
* @param {Object} ajaxHeaders Updated AJAX headers, which will be merged over any headers specified in {@link OpenSeadragon.Options}.
* @param {Boolean} [propagate=true] Whether to propagate updated headers to existing tiles and queued image loader jobs.
*/
setAjaxHeaders: function(ajaxHeaders, propagate) {
if (ajaxHeaders === null) {
ajaxHeaders = {};
}
if (!$.isPlainObject(ajaxHeaders)) {
console.error('[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object');
return;
}
this._ownAjaxHeaders = ajaxHeaders;
this._updateAjaxHeaders(propagate);
},
/**
* Update headers to include when making AJAX requests.
*
* This function has the same effect as calling {@link OpenSeadragon.TiledImage#setAjaxHeaders},
* except that the headers for this tiled image do not change. This is especially useful
* for propagating updated headers from {@link OpenSeadragon.TileSource#getTileAjaxHeaders}
* to existing tiles.
*
* @private
* @function
* @param {Boolean} [propagate=true] Whether to propagate updated headers to existing tiles and queued image loader jobs.
*/
_updateAjaxHeaders: function(propagate) {
if (propagate === undefined) {
propagate = true;
}
// merge with viewer's headers
if ($.isPlainObject(this.viewer.ajaxHeaders)) {
this.ajaxHeaders = $.extend({}, this.viewer.ajaxHeaders, this._ownAjaxHeaders);
} else {
this.ajaxHeaders = this._ownAjaxHeaders;
}
// propagate header updates to all tiles and queued image loader jobs
if (propagate) {
var numTiles, xMod, yMod, tile;
for (var level in this.tilesMatrix) {
numTiles = this.source.getNumTiles(level);
for (var x in this.tilesMatrix[level]) {
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
for (var y in this.tilesMatrix[level][x]) {
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
tile = this.tilesMatrix[level][x][y];
tile.loadWithAjax = this.loadTilesWithAjax;
if (tile.loadWithAjax) {
var tileAjaxHeaders = this.source.getTileAjaxHeaders( level, xMod, yMod );
tile.ajaxHeaders = $.extend({}, this.ajaxHeaders, tileAjaxHeaders);
} else {
tile.ajaxHeaders = null;
}
}
}
}
for (var i = 0; i < this._imageLoader.jobQueue.length; i++) {
var job = this._imageLoader.jobQueue[i];
job.loadWithAjax = job.tile.loadWithAjax;
job.ajaxHeaders = job.tile.loadWithAjax ? job.tile.ajaxHeaders : null;
}
}
},
// private
_setScale: function(scale, immediately) {
var sameTarget = (this._scaleSpring.target.value === scale);
@ -1118,7 +1209,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
var levelsInterval = this._getLevelsInterval();
var lowestLevel = levelsInterval.lowestLevel;
var highestLevel = levelsInterval.highestLevel;
var bestTile = null;
var bestTiles = [];
var haveDrawn = false;
var currentTime = $.now();
@ -1163,7 +1254,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
);
// Update the level and keep track of 'best' tile to load
bestTile = this._updateLevel(
bestTiles = this._updateLevel(
haveDrawn,
drawLevel,
level,
@ -1171,7 +1262,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
levelVisibility,
drawArea,
currentTime,
bestTile
bestTiles
);
// Stop the loop if lower-res tiles would all be covered by
@ -1184,9 +1275,13 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// Perform the actual drawing
this._drawTiles(this.lastDrawn);
// Load the new 'best' tile
if (bestTile && !bestTile.context2D) {
this._loadTile(bestTile, currentTime);
// Load the new 'best' n tiles
if (bestTiles && bestTiles.length > 0) {
bestTiles.forEach(function (tile) {
if (tile && !tile.context2D) {
this._loadTile(tile, currentTime);
}
}, this);
this._needsDraw = true;
this._setFullyLoaded(false);
} else {
@ -1245,7 +1340,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
* @param {Number} levelVisibility
* @param {OpenSeadragon.Rect} drawArea
* @param {Number} currentTime
* @param {OpenSeadragon.Tile} best - The current "best" tile to draw.
* @param {OpenSeadragon.Tile[]} best - The current "best" n tiles to draw.
*/
_updateLevel: function(haveDrawn, drawLevel, level, levelOpacity,
levelVisibility, drawArea, currentTime, best) {
@ -1270,7 +1365,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
* @property {Object} topleft deprecated, use drawArea instead
* @property {Object} bottomright deprecated, use drawArea instead
* @property {Object} currenttime
* @property {Object} best
* @property {Object[]} best
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.viewer.raiseEvent('update-level', {
@ -1359,7 +1454,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
* @param {OpenSeadragon.Point} viewportCenter
* @param {Number} numberOfTiles
* @param {Number} currentTime
* @param {OpenSeadragon.Tile} best - The current "best" tile to draw.
* @param {OpenSeadragon.Tile[]} best - The current "best" tiles to draw.
*/
_updateTile: function( haveDrawn, drawLevel, x, y, level, levelOpacity,
levelVisibility, viewportCenter, numberOfTiles, currentTime, best){
@ -1448,7 +1543,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// the tile is already in the download queue
this._tilesLoading++;
} else if (!loadingCoverage) {
best = this._compareTiles( best, tile );
best = this._compareTiles( best, tile, this.maxTilesPerFrame );
}
return best;
@ -1621,6 +1716,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
tile.loading = false;
tile.exists = false;
return;
} else {
tile.exists = true;
}
if ( time < this.lastResetTime ) {
@ -1656,9 +1753,14 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
*/
_setTileLoaded: function(tile, data, cutoff, tileRequest) {
var increment = 0,
eventFinished = false,
_this = this;
function getCompletionCallback() {
if (eventFinished) {
$.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. " +
"Its return value should be called asynchronously.");
}
increment++;
return completionCallback;
}
@ -1700,6 +1802,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
* marked as entirely loaded when the callback has been called once for each
* call to getCompletionCallback.
*/
var fallbackCompletion = getCompletionCallback();
this.viewer.raiseEvent("tile-loaded", {
tile: tile,
tiledImage: this,
@ -1711,8 +1815,9 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
data: data,
getCompletionCallback: getCompletionCallback
});
eventFinished = true;
// In case the completion callback is never called, we at least force it once.
getCompletionCallback()();
fallbackCompletion();
},
/**
@ -1812,28 +1917,49 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
/**
* @private
* @inner
* Determines whether the 'last best' tile for the area is better than the
* Determines the 'best tiles' from the given 'last best' tiles and the
* tile in question.
*
* @param {OpenSeadragon.Tile} previousBest
* @param {OpenSeadragon.Tile} tile
* @returns {OpenSeadragon.Tile} The new best tile.
* @param {OpenSeadragon.Tile[]} previousBest The best tiles so far.
* @param {OpenSeadragon.Tile} tile The new tile to consider.
* @param {Number} maxNTiles The max number of best tiles.
* @returns {OpenSeadragon.Tile[]} The new best tiles.
*/
_compareTiles: function( previousBest, tile ) {
_compareTiles: function( previousBest, tile, maxNTiles ) {
if ( !previousBest ) {
return tile;
return [tile];
}
if ( tile.visibility > previousBest.visibility ) {
return tile;
} else if ( tile.visibility === previousBest.visibility ) {
if ( tile.squaredDistance < previousBest.squaredDistance ) {
return tile;
}
previousBest.push(tile);
this._sortTiles(previousBest);
if (previousBest.length > maxNTiles) {
previousBest.pop();
}
return previousBest;
},
/**
* @private
* @inner
* Sorts tiles in an array according to distance and visibility.
*
* @param {OpenSeadragon.Tile[]} tiles The tiles.
*/
_sortTiles: function( tiles ) {
tiles.sort(function (a, b) {
if (a === null) {
return 1;
}
if (b === null) {
return -1;
}
if (a.visibility === b.visibility) {
return (a.squaredDistance - b.squaredDistance);
} else {
return (a.visibility - b.visibility);
}
});
},
/**
* @private
* @inner
@ -1864,7 +1990,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
if (lastDrawn.length > 1 &&
imageZoom > this.smoothTileEdgesMinZoom &&
!this.iOSDevice &&
this.getRotation(true) % 360 === 0 && // TODO: support tile edge smoothing with tiled image rotation.
this.getRotation(true) % 360 === 0 && // TODO: support tile edge smoothing with tiled image rotation (viewport rotation is not a problem).
this._drawer.viewer.viewport.getFlip() === false && // TODO: support tile edge smoothing with viewport flip (tiled image flip is not a problem).
$.supportsCanvas && this.viewer.useCanvas) {
// When zoomed in a lot (>100%) the tile edges are visible.
// So we have to composite them at ~100% and scale them up together.
@ -1954,6 +2081,9 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
if (sketchScale) {
clipPoint = clipPoint.times(sketchScale);
}
if (sketchTranslate) {
clipPoint = clipPoint.plus(sketchTranslate);
}
return clipPoint;
});
});

View File

@ -2,7 +2,7 @@
* OpenSeadragon - TileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -663,6 +663,11 @@ $.TileSource.prototype = {
* The headers returned here will override headers specified at the Viewer or TiledImage level.
* Specifying a falsy value for a header will clear its existing value set at the Viewer or
* TiledImage level (if any).
*
* Note that the headers of existing tiles don't automatically change when this function
* returns updated headers. To do that, you need to call {@link OpenSeadragon.Viewer#setAjaxHeaders}
* and propagate the changes.
*
* @function
* @param {Number} level
* @param {Number} x
@ -932,7 +937,7 @@ function processResponse( xhr ){
throw new Error( $.getString( "Errors.Status", status, statusText ) );
}
if( responseText.match(/\s*<.*/) ){
if( responseText.match(/^\s*<.*/) ){
try{
data = ( xhr.responseXML && xhr.responseXML.documentElement ) ?
xhr.responseXML :

View File

@ -2,7 +2,7 @@
* OpenSeadragon - TileSourceCollection
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - TmsTileSource
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Viewer
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -307,7 +307,9 @@ $.Viewer = function( options ) {
nonPrimaryPressHandler: $.delegate( this, onCanvasNonPrimaryPress ),
nonPrimaryReleaseHandler: $.delegate( this, onCanvasNonPrimaryRelease ),
scrollHandler: $.delegate( this, onCanvasScroll ),
pinchHandler: $.delegate( this, onCanvasPinch )
pinchHandler: $.delegate( this, onCanvasPinch ),
focusHandler: $.delegate( this, onCanvasFocus ),
blurHandler: $.delegate( this, onCanvasBlur ),
});
this.outerTracker = new $.MouseTracker({
@ -964,7 +966,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
* Turns debugging mode on or off for this viewer.
*
* @function
* @param {Boolean} true to turn debug on, false to turn debug off.
* @param {Boolean} debugMode true to turn debug on, false to turn debug off.
*/
setDebugMode: function(debugMode){
@ -976,6 +978,63 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
this.forceRedraw();
},
/**
* Update headers to include when making AJAX requests.
*
* Unless `propagate` is set to false (which is likely only useful in rare circumstances),
* the updated headers are propagated to all tiled images, each of which will subsequently
* propagate the changed headers to all their tiles.
* If applicable, the headers of the viewer's navigator and reference strip will also be updated.
*
* Note that the rules for merging headers still apply, i.e. headers returned by
* {@link OpenSeadragon.TileSource#getTileAjaxHeaders} take precedence over
* `TiledImage.ajaxHeaders`, which take precedence over the headers here in the viewer.
*
* @function
* @param {Object} ajaxHeaders Updated AJAX headers.
* @param {Boolean} [propagate=true] Whether to propagate updated headers to tiled images, etc.
*/
setAjaxHeaders: function(ajaxHeaders, propagate) {
if (ajaxHeaders === null) {
ajaxHeaders = {};
}
if (!$.isPlainObject(ajaxHeaders)) {
console.error('[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object');
return;
}
if (propagate === undefined) {
propagate = true;
}
this.ajaxHeaders = ajaxHeaders;
if (propagate) {
for (var i = 0; i < this.world.getItemCount(); i++) {
this.world.getItemAt(i)._updateAjaxHeaders(true);
}
if (this.navigator) {
this.navigator.setAjaxHeaders(this.ajaxHeaders, true);
}
if (this.referenceStrip && this.referenceStrip.miniViewers) {
for (var key in this.referenceStrip.miniViewers) {
this.referenceStrip.miniViewers[key].setAjaxHeaders(this.ajaxHeaders, true);
}
}
}
},
/**
* Adds the given button to this viewer.
*
* @function
* @param {OpenSeadragon.Button} button
*/
addButton: function( button ){
this.buttonGroup.addButton(button);
},
/**
* @function
* @returns {Boolean}
@ -1390,7 +1449,6 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
* A set of headers to include when making tile AJAX requests.
* Note that these headers will be merged over any headers specified in {@link OpenSeadragon.Options}.
* Specifying a falsy value for a header will clear its existing value set at the Viewer level (if any).
* requests.
* @param {Function} [options.success] A function that gets called when the image is
* successfully added. It's passed the event object which contains a single property:
* "item", which is the resulting instance of TiledImage.
@ -1438,10 +1496,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
if (options.loadTilesWithAjax === undefined) {
options.loadTilesWithAjax = this.loadTilesWithAjax;
}
if (options.ajaxHeaders === undefined || options.ajaxHeaders === null) {
options.ajaxHeaders = this.ajaxHeaders;
} else if ($.isPlainObject(options.ajaxHeaders) && $.isPlainObject(this.ajaxHeaders)) {
options.ajaxHeaders = $.extend({}, this.ajaxHeaders, options.ajaxHeaders);
if (!$.isPlainObject(options.ajaxHeaders)) {
options.ajaxHeaders = {};
}
var myQueueItem = {
@ -1548,6 +1604,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
minZoomImageRatio: _this.minZoomImageRatio,
wrapHorizontal: _this.wrapHorizontal,
wrapVertical: _this.wrapVertical,
maxTilesPerFrame: _this.maxTilesPerFrame,
immediateRender: _this.immediateRender,
blendTime: _this.blendTime,
alwaysBlend: _this.alwaysBlend,
@ -2757,7 +2814,7 @@ function onCanvasKeyDown( event ) {
if ( !canvasKeyDownEventArgs.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
switch( event.keyCode ){
case 38://up arrow
case 38://up arrow/shift uparrow
if (!canvasKeyDownEventArgs.preventVerticalPan) {
if ( event.shift ) {
this.viewport.zoomBy(1.1);
@ -2768,7 +2825,7 @@ function onCanvasKeyDown( event ) {
}
event.preventDefault = true;
break;
case 40://down arrow
case 40://down arrow/shift downarrow
if (!canvasKeyDownEventArgs.preventVerticalPan) {
if ( event.shift ) {
this.viewport.zoomBy(0.9);
@ -2793,6 +2850,84 @@ function onCanvasKeyDown( event ) {
}
event.preventDefault = true;
break;
case 187://=|+
this.viewport.zoomBy(1.1);
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 189://-|_
this.viewport.zoomBy(0.9);
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 48://0|)
this.viewport.goHome();
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 87://W/w
if (!canvasKeyDownEventArgs.preventVerticalPan) {
if ( event.shift ) {
this.viewport.zoomBy(1.1);
} else {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, -40)));
}
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 83://S/s
if (!canvasKeyDownEventArgs.preventVerticalPan) {
if ( event.shift ) {
this.viewport.zoomBy(0.9);
} else {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, 40)));
}
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 65://a/A
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-40, 0)));
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 68://d/D
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(40, 0)));
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 82: //r - clockwise rotation/R - counterclockwise rotation
if(event.shift){
if(this.viewport.flipped){
this.viewport.setRotation(this.viewport.getRotation() + this.rotationIncrement);
} else{
this.viewport.setRotation(this.viewport.getRotation() - this.rotationIncrement);
}
}else{
if(this.viewport.flipped){
this.viewport.setRotation(this.viewport.getRotation() - this.rotationIncrement);
} else{
this.viewport.setRotation(this.viewport.getRotation() + this.rotationIncrement);
}
}
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 70: //f/F
this.viewport.toggleFlip();
event.preventDefault = true;
break;
case 74: //j - previous image source
this.goToPreviousPage();
break;
case 75: //k - next image source
this.goToNextPage();
break;
default:
//console.log( 'navigator keycode %s', event.keyCode );
event.preventDefault = false;
@ -2802,12 +2937,10 @@ function onCanvasKeyDown( event ) {
event.preventDefault = false;
}
}
function onCanvasKeyPress( event ) {
var canvasKeyPressEventArgs = {
originalEvent: event.originalEvent,
preventDefaultAction: false,
preventVerticalPan: event.preventVerticalPan || !this.panVertical,
preventHorizontalPan: event.preventHorizontalPan || !this.panHorizontal
};
/**
@ -2818,109 +2951,12 @@ function onCanvasKeyPress( event ) {
* @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
* @property {Object} originalEvent - The original DOM event.
* @property {Boolean} preventDefaultAction - Set to true to prevent default keyboard behaviour. Default: false.
* @property {Boolean} preventVerticalPan - Set to true to prevent keyboard vertical panning. Default: false.
* @property {Boolean} preventHorizontalPan - Set to true to prevent keyboard horizontal panning. Default: false.
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.raiseEvent('canvas-key-press', canvasKeyPressEventArgs);
if ( !canvasKeyPressEventArgs.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
switch( event.keyCode ){
case 43://=|+
case 61://=|+
this.viewport.zoomBy(1.1);
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 45://-|_
this.viewport.zoomBy(0.9);
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 48://0|)
this.viewport.goHome();
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 119://w
case 87://W
if (!canvasKeyPressEventArgs.preventVerticalPan) {
if ( event.shift ) {
this.viewport.zoomBy(1.1);
} else {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, -40)));
}
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 115://s
case 83://S
if (!canvasKeyPressEventArgs.preventVerticalPan) {
if ( event.shift ) {
this.viewport.zoomBy(0.9);
} else {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, 40)));
}
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 97://a
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-40, 0)));
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 100://d
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(40, 0)));
this.viewport.applyConstraints();
}
event.preventDefault = true;
break;
case 114: //r - clockwise rotation
if(this.viewport.flipped){
this.viewport.setRotation(this.viewport.getRotation() - this.rotationIncrement);
} else{
this.viewport.setRotation(this.viewport.getRotation() + this.rotationIncrement);
}
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 82: //R - counterclockwise rotation
if(this.viewport.flipped){
this.viewport.setRotation(this.viewport.getRotation() + this.rotationIncrement);
} else{
this.viewport.setRotation(this.viewport.getRotation() - this.rotationIncrement);
}
this.viewport.applyConstraints();
event.preventDefault = true;
break;
case 102: //f
this.viewport.toggleFlip();
event.preventDefault = true;
break;
case 106: //j - previous image source
this.goToPreviousPage();
break;
case 107: //k - next image source
this.goToNextPage();
break;
default:
// console.log( 'navigator keycode %s', event.keyCode );
event.preventDefault = false;
break;
}
} else {
event.preventDefault = false;
}
}
function onCanvasClick( event ) {
var gestureSettings;
@ -3431,11 +3467,49 @@ function onCanvasPinch( event ) {
event.gesturePoints[0].currentPos.x - event.gesturePoints[1].currentPos.x);
var angle2 = Math.atan2(event.gesturePoints[0].lastPos.y - event.gesturePoints[1].lastPos.y,
event.gesturePoints[0].lastPos.x - event.gesturePoints[1].lastPos.x);
this.viewport.setRotation(this.viewport.getRotation() + ((angle1 - angle2) * (180 / Math.PI)));
centerPt = this.viewport.pointFromPixel( event.center, true );
this.viewport.rotateTo(this.viewport.getRotation(true) + ((angle1 - angle2) * (180 / Math.PI)), centerPt, true);
}
}
}
function onCanvasFocus( event ) {
/**
* Raised when the {@link OpenSeadragon.Viewer#canvas} element gets keyboard focus.
*
* @event canvas-focus
* @memberof OpenSeadragon.Viewer
* @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
* @property {Object} originalEvent - The original DOM event.
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.raiseEvent( 'canvas-focus', {
tracker: event.eventSource,
originalEvent: event.originalEvent
});
}
function onCanvasBlur( event ) {
/**
* Raised when the {@link OpenSeadragon.Viewer#canvas} element loses keyboard focus.
*
* @event canvas-blur
* @memberof OpenSeadragon.Viewer
* @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
* @property {Object} originalEvent - The original DOM event.
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.raiseEvent( 'canvas-blur', {
tracker: event.eventSource,
originalEvent: event.originalEvent
});
}
function onCanvasScroll( event ) {
var canvasScrollEventArgs,
gestureSettings,

View File

@ -2,7 +2,7 @@
* OpenSeadragon - Viewport
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -711,6 +711,8 @@ $.Viewport.prototype = {
if(constraints){
this.panTo(center, false);
newZoom = this._applyZoomConstraints(newZoom);
this.zoomTo(newZoom, null, false);
var constrainedBounds = this.getConstrainedBounds();
@ -1076,7 +1078,10 @@ $.Viewport.prototype = {
if( this.viewer ){
/**
* Raised when the viewer is resized (see {@link OpenSeadragon.Viewport#resize}).
* Raised when a viewer resize operation is initiated (see {@link OpenSeadragon.Viewport#resize}).
* This event happens before the viewport bounds have been updated.
* See also {@link OpenSeadragon.Viewer#after-resize} which reflects
* the new viewport bounds following the resize action.
*
* @event resize
* @memberof OpenSeadragon.Viewer
@ -1092,7 +1097,29 @@ $.Viewport.prototype = {
});
}
return this.fitBounds( newBounds, true );
var output = this.fitBounds( newBounds, true );
if( this.viewer ){
/**
* Raised after the viewer is resized (see {@link OpenSeadragon.Viewport#resize}).
* See also {@link OpenSeadragon.Viewer#resize} event which happens
* before the new bounds have been calculated and applied.
*
* @event after-resize
* @memberof OpenSeadragon.Viewer
* @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
* @property {OpenSeadragon.Point} newContainerSize
* @property {Boolean} maintain
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.viewer.raiseEvent( 'after-resize', {
newContainerSize: newContainerSize,
maintain: maintain
});
}
return output;
},
// private

View File

@ -2,7 +2,7 @@
* OpenSeadragon - World
*
* Copyright (C) 2009 CodePlex Foundation
* Copyright (C) 2010-2022 OpenSeadragon contributors
* Copyright (C) 2010-2023 OpenSeadragon contributors
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>OpenSeadragon QUnit</title>
<link rel="stylesheet" href="/node_modules/qunitjs/qunit/qunit.css">
<link rel="stylesheet" href="/node_modules/qunit/qunit/qunit.css">
<link rel="stylesheet" href="/test/lib/jquery-ui-1.10.2/css/smoothness/jquery-ui-1.10.2.min.css">
<link rel="stylesheet" href="/test/helpers/test.css">
</head>
@ -15,7 +15,7 @@
var isCoverageTest = true;
</script>
<script src="/node_modules/qunitjs/qunit/qunit.js"></script>
<script src="/node_modules/qunit/qunit/qunit.js"></script>
<script src="/test/lib/jquery-1.9.1.min.js"></script>
<script src="/test/lib/jquery-ui-1.10.2/js/jquery-ui-1.10.2.min.js"></script>
<script src="/test/lib/jquery.simulate.js"></script>

View File

@ -18,7 +18,8 @@
"jpg",
"png",
"gif"
]
]
}
]
],
"xmp": "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\"\n xmlns:xmp=\"http://ns.adobe.com/xap/1.0/\"\n xmlns:aux=\"http://ns.adobe.com/exif/1.0/aux/\"\n xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\"\n xmlns:Iptc4xmpCore=\"http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/\"\n xmlns:tiff=\"http://ns.adobe.com/tiff/1.0/\"\n xmlns:exif=\"http://ns.adobe.com/exif/1.0/\"\n xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n xmp:CreatorTool=\"Capture One 11 Macintosh\"\n xmp:CreateDate=\"2019-08-21T20:54:20\"\n xmp:Rating=\"4\"\n aux:SerialNumber=\"GP001601\"\n aux:ImageNumber=\"30012\"\n aux:Firmware=\"IQ280, Factory Firmware: 8.05.36\"\n photoshop:CaptionWriter=\"\"\n photoshop:Headline=\"\"\n photoshop:City=\"\"\n photoshop:State=\"\"\n photoshop:Country=\"\"\n photoshop:Source=\"\"\n photoshop:Instructions=\"\"\n photoshop:AuthorsPosition=\"\"\n photoshop:TransmissionReference=\"\"\n photoshop:Credit=\"\"\n photoshop:LegacyIPTCDigest=\"B135BFFD6A4CFB049F834A3F370A9AE3\"\n photoshop:DateCreated=\"2019-08-21T20:54:20\"\n Iptc4xmpCore:Location=\"\"\n Iptc4xmpCore:IntellectualGenre=\"\"\n Iptc4xmpCore:CountryCode=\"\"\n tiff:ImageWidth=\"2088\"\n tiff:ImageLength=\"3000\"\n tiff:Compression=\"1\"\n tiff:PhotometricInterpretation=\"2\"\n tiff:Orientation=\"1\"\n tiff:SamplesPerPixel=\"3\"\n tiff:PlanarConfiguration=\"1\"\n tiff:XResolution=\"400/1\"\n tiff:YResolution=\"400/1\"\n tiff:ResolutionUnit=\"2\"\n tiff:Make=\"Phase One\"\n tiff:Model=\"IQ280\"\n tiff:Software=\"Capture One 11 Macintosh\"\n exif:ExifVersion=\"0230\"\n exif:PixelXDimension=\"2088\"\n exif:PixelYDimension=\"3000\"\n exif:ExposureTime=\"1/4\"\n exif:ExposureProgram=\"1\"\n exif:ShutterSpeedValue=\"2/1\"\n exif:MeteringMode=\"1\"\n exif:LightSource=\"255\"\n exif:FocalPlaneXResolution=\"63015385/32768\"\n exif:FocalPlaneYResolution=\"63015385/32768\"\n exif:FocalPlaneResolutionUnit=\"3\"\n exif:FileSource=\"3\"\n exif:SceneType=\"1\"\n exif:WhiteBalance=\"5\"\n exif:ImageUniqueID=\"00E058000075000004019E064100753C\">\n <Iptc4xmpCore:CreatorContactInfo\n Iptc4xmpCore:CiEmailWork=\"digicc@library.illinois.edu\"\n Iptc4xmpCore:CiTelWork=\"+1(217)2442062\"\n Iptc4xmpCore:CiAdrPcode=\"61801\"\n Iptc4xmpCore:CiUrlWork=\"http://www.library.illinois.edu/staff/preservation/digitization/\"\n Iptc4xmpCore:CiAdrExtadr=\"1408 W. Gregory Drive\"\n Iptc4xmpCore:CiAdrCity=\"Urbana\"\n Iptc4xmpCore:CiAdrCtry=\"United States\"\n Iptc4xmpCore:CiAdrRegion=\"Illinois\"/>\n <tiff:BitsPerSample>\n <rdf:Seq>\n <rdf:li>8 8 8</rdf:li>\n </rdf:Seq>\n </tiff:BitsPerSample>\n <exif:ISOSpeedRatings>\n <rdf:Seq>\n <rdf:li>50</rdf:li>\n </rdf:Seq>\n </exif:ISOSpeedRatings>\n <dc:creator>\n <rdf:Seq>\n <rdf:li>University of Illinois Library</rdf:li>\n </rdf:Seq>\n </dc:creator>\n </rdf:Description>\n </rdf:RDF>"
}

View File

@ -25,7 +25,7 @@
id: "contentDiv",
prefixUrl: "../../build/openseadragon/images/",
tileSources: "../data/testpattern.dzi",
showNavigator:true
showNavigator: true
});
</script>
</body>

View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>OpenSeadragon maxTilesPerFrame Demo</title>
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
<script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
<style type="text/css">
.openseadragon1 {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<div>
Simple demo page to show an OpenSeadragon viewer with a higher maxTilesPerFrame.
</div>
<div id="contentDiv" class="openseadragon1"></div>
<script type="text/javascript">
var viewer = OpenSeadragon({
debugMode: true,
id: "contentDiv",
prefixUrl: "../../build/openseadragon/images/",
tileSources: "https://openseadragon.github.io/example-images/duomo/duomo.dzi",
showNavigator:true,
debugMode:true,
maxTilesPerFrame:3,
});
</script>
</body>
</html>

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<title>OpenSeadragon Basic Demo</title>
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
<script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
<style type="text/css">
.openseadragon1 {
width: 800px;
height: 600px;
}
</style>
</head>
<body>
<div>
Simple demo page. The navigator region is expected to rotate when the image is rotated.
The default behaviour is to keep the region still as the image below it rotates.
</div>
<div id="contentDiv" class="openseadragon1"></div>
<script type="text/javascript">
var viewer = OpenSeadragon({
// debugMode: true,
id: "contentDiv",
prefixUrl: "../../build/openseadragon/images/",
tileSources: "../data/testpattern.dzi",
showNavigator: true,
navigatorRotate: false
});
viewer.viewport.setRotation(45)
</script>
</body>
</html>

View File

@ -245,4 +245,130 @@
tileSource: staticHeaderTileSource
});
});
QUnit.test('Viewer headers can be updated', function(assert) {
var done = assert.async();
var newHeaders = {
'X-Viewer-Header': 'ViewerHeaderValue-Updated',
'X-Viewer-Header2': 'ViewerHeaderValue2'
}
var newHeaders2 = {
Range: 'test',
}
var tileLoaded = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded);
// set new Viewer headers and propagate to TiledImage and Tile
viewer.setAjaxHeaders(newHeaders);
viewer.addHandler('tile-loaded', tileLoaded2);
};
var tileLoaded2 = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded2);
assert.deepEqual(viewer.ajaxHeaders, newHeaders);
assert.deepEqual(evt.tiledImage.ajaxHeaders, newHeaders);
assert.deepEqual(
evt.tile.ajaxHeaders,
OpenSeadragon.extend(
{}, viewer.ajaxHeaders, evt.tiledImage.ajaxHeaders,
{ Range: getTileRangeHeader(evt.tile.level, evt.tile.x, evt.tile.y) }
)
);
// set new Viewer headers and propagate to TiledImage and Tile
viewer.setAjaxHeaders(newHeaders2, true);
viewer.addHandler('tile-loaded', tileLoaded3);
};
var tileLoaded3 = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded3);
assert.deepEqual(viewer.ajaxHeaders, newHeaders2);
assert.deepEqual(evt.tiledImage.ajaxHeaders, newHeaders2);
assert.equal(evt.tile.ajaxHeaders['X-Viewer-Header'], undefined);
assert.equal(evt.tile.ajaxHeaders['X-Viewer-Header2'], undefined);
// 'Range' header entry set per tile and must not be overwritten by Viewer header
assert.equal(evt.tile.ajaxHeaders.Range, getTileRangeHeader(evt.tile.level, evt.tile.x, evt.tile.y));
// set new Viewer headers but do not propagate to TiledImage and Tile
viewer.setAjaxHeaders(newHeaders, false);
viewer.addHandler('tile-loaded', tileLoaded4);
};
var tileLoaded4 = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded4);
assert.deepEqual(viewer.ajaxHeaders, newHeaders);
assert.deepEqual(evt.tiledImage.ajaxHeaders, newHeaders2);
assert.equal(evt.tile.ajaxHeaders['X-Viewer-Header'], undefined);
assert.equal(evt.tile.ajaxHeaders['X-Viewer-Header2'], undefined);
done();
};
viewer.addHandler('tile-loaded', tileLoaded);
viewer.open(customTileSource);
});
QUnit.test('TiledImage headers can be updated', function(assert) {
var done = assert.async();
var tileSourceHeaders = {
'X-Tile-Header': 'TileHeaderValue'
}
var newHeaders = {
'X-TiledImage-Header': 'TiledImageHeaderValue-Updated',
'X-TiledImage-Header2': 'TiledImageHeaderValue2'
}
var newHeaders2 = {
'X-Viewer-Header': 'ViewerHeaderValue-Updated',
'X-Tile-Header': 'TileHeaderValue-Updated'
}
var tileLoaded = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded);
// set new TiledImage headers and propagate to Tile
evt.tiledImage.setAjaxHeaders(newHeaders);
viewer.addHandler('tile-loaded', tileLoaded2);
};
var tileLoaded2 = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded2);
assert.deepEqual(viewer.ajaxHeaders, { 'X-Viewer-Header': 'ViewerHeaderValue' });
assert.deepEqual(evt.tiledImage._ownAjaxHeaders, newHeaders);
assert.deepEqual(evt.tiledImage.ajaxHeaders, OpenSeadragon.extend({}, viewer.ajaxHeaders, newHeaders));
assert.deepEqual(evt.tile.ajaxHeaders, OpenSeadragon.extend({}, viewer.ajaxHeaders, newHeaders, tileSourceHeaders));
// set new TiledImage headers (that overwrite header entries of Viewer and Tile) and propagate to Tile
evt.tiledImage.setAjaxHeaders(newHeaders2, true);
viewer.addHandler('tile-loaded', tileLoaded3);
};
var tileLoaded3 = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded3);
assert.deepEqual(viewer.ajaxHeaders, { 'X-Viewer-Header': 'ViewerHeaderValue' });
assert.deepEqual(evt.tiledImage._ownAjaxHeaders, newHeaders2);
assert.deepEqual(evt.tiledImage.ajaxHeaders, OpenSeadragon.extend({}, viewer.ajaxHeaders, newHeaders2));
assert.deepEqual(evt.tile.ajaxHeaders, OpenSeadragon.extend({}, viewer.ajaxHeaders, newHeaders2, tileSourceHeaders));
// set new TiledImage headers but do not propagate to Tile
evt.tiledImage.setAjaxHeaders(null, false);
viewer.addHandler('tile-loaded', tileLoaded4);
};
var tileLoaded4 = function tileLoaded(evt) {
viewer.removeHandler('tile-loaded', tileLoaded4);
assert.deepEqual(viewer.ajaxHeaders, { 'X-Viewer-Header': 'ViewerHeaderValue' });
assert.deepEqual(evt.tiledImage._ownAjaxHeaders, {});
assert.deepEqual(evt.tiledImage.ajaxHeaders, viewer.ajaxHeaders);
assert.deepEqual(evt.tile.ajaxHeaders, OpenSeadragon.extend({}, viewer.ajaxHeaders, newHeaders2, tileSourceHeaders));
done();
};
viewer.addHandler('tile-loaded', tileLoaded);
viewer.addTiledImage({
ajaxHeaders: {
'X-TiledImage-Header': 'TiledImageHeaderValue'
},
tileSource: OpenSeadragon.extend({}, customTileSource, {
getTileAjaxHeaders: function() {
return tileSourceHeaders;
}
}),
});
});
})();

View File

@ -224,32 +224,43 @@
});
QUnit.test('FullScreen', function(assert) {
var done = assert.async();
const done = assert.async();
if (!OpenSeadragon.supportsFullScreen) {
assert.expect(0);
done();
return;
}
viewer.addHandler("open", function () {
viewer.addHandler('open', function () {
assert.ok(!OpenSeadragon.isFullScreen(), 'Started out not fullscreen');
var checkEnteringPreFullScreen = function(event) {
const checkEnteringPreFullScreen = (event) => {
viewer.removeHandler('pre-full-screen', checkEnteringPreFullScreen);
assert.ok(event.fullScreen, 'Switching to fullscreen');
assert.ok(!OpenSeadragon.isFullScreen(), 'Not yet fullscreen');
};
// The fullscreen mode is always denied during tests so we are
// exiting directly.
var checkExitingFullScreen = function(event) {
const checkExitingFullScreen = (event) => {
viewer.removeHandler('full-screen', checkExitingFullScreen);
assert.ok(!event.fullScreen, 'Exiting fullscreen');
assert.ok(!OpenSeadragon.isFullScreen(), 'Disabled fullscreen');
assert.ok(!event.fullScreen, 'Disabling fullscreen');
assert.ok(!OpenSeadragon.isFullScreen(), 'Fullscreen disabled');
done();
}
// The 'new' headless mode allows us to enter fullscreen, so verify
// that we see the correct values returned. We will then close out
// of fullscreen to check the same values when exiting.
const checkAcquiredFullScreen = (event) => {
viewer.removeHandler('full-screen', checkAcquiredFullScreen);
viewer.addHandler('full-screen', checkExitingFullScreen);
assert.ok(event.fullScreen, 'Acquired fullscreen');
assert.ok(OpenSeadragon.isFullScreen(), 'Fullscreen enabled');
viewer.setFullScreen(false);
};
viewer.addHandler("pre-full-screen", checkEnteringPreFullScreen);
viewer.addHandler("full-screen", checkExitingFullScreen);
viewer.addHandler('pre-full-screen', checkEnteringPreFullScreen);
viewer.addHandler('full-screen', checkAcquiredFullScreen);
viewer.setFullScreen(true);
});

View File

@ -3,14 +3,14 @@
<head>
<meta charset="utf-8">
<title>OpenSeadragon QUnit</title>
<link rel="stylesheet" href="/node_modules/qunitjs/qunit/qunit.css">
<link rel="stylesheet" href="/node_modules/qunit/qunit/qunit.css">
<link rel="stylesheet" href="/test/lib/jquery-ui-1.10.2/css/smoothness/jquery-ui-1.10.2.min.css">
<link rel="stylesheet" href="/test/helpers/test.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="/node_modules/qunitjs/qunit/qunit.js"></script>
<script src="/node_modules/qunit/qunit/qunit.js"></script>
<script src="/test/lib/jquery-1.9.1.min.js"></script>
<script src="/test/lib/jquery-ui-1.10.2/js/jquery-ui-1.10.2.min.js"></script>
<script src="/test/lib/jquery.simulate.js"></script>