@projektemacher/storymapjs 0.10.6 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG +11 -0
  2. package/dist/assets/{demo-CVQ7kFek.js → demo-D6cTmzn6.js} +1 -1
  3. package/dist/assets/{harness-C-VZV-ou.js → harness-BPFlzutp.js} +1 -1
  4. package/dist/assets/main-Y-MYUSJ4.js +17 -0
  5. package/dist/css/fonts/font.oldstandard.css +18 -22
  6. package/dist/demo.html +2 -2
  7. package/dist/docs/migration.html +1 -1
  8. package/dist/embed/index.html +129 -4
  9. package/dist/harness.html +2 -2
  10. package/dist/index.html +17 -0
  11. package/dist/js/storymap.d.ts +126 -7
  12. package/dist/js/storymap.js +4518 -3613
  13. package/dist/js/storymap.js.map +1 -1
  14. package/docs/migration-from-knightlab.md +139 -0
  15. package/docs/storymap-as-iiif-manifest.md +510 -0
  16. package/package.json +6 -3
  17. package/src/animation/easings.ts +18 -0
  18. package/src/animation/morpheus.d.ts +41 -0
  19. package/src/core/Browser.ts +19 -0
  20. package/src/core/Load.ts +180 -0
  21. package/src/core/Util.ts +354 -0
  22. package/src/core/mixins.ts +171 -0
  23. package/src/dom/Dom.ts +31 -0
  24. package/src/dom/DomEvent.ts +61 -0
  25. package/src/globals.d.ts +16 -0
  26. package/src/language/Language.ts +107 -0
  27. package/src/language/locale/be.json +18 -0
  28. package/src/language/locale/bg.json +18 -0
  29. package/src/language/locale/cs.json +18 -0
  30. package/src/language/locale/de.json +20 -0
  31. package/src/language/locale/el.json +18 -0
  32. package/src/language/locale/en.json +28 -0
  33. package/src/language/locale/es.json +18 -0
  34. package/src/language/locale/et.json +18 -0
  35. package/src/language/locale/fr.json +18 -0
  36. package/src/language/locale/he.json +18 -0
  37. package/src/language/locale/hu.json +18 -0
  38. package/src/language/locale/is.json +18 -0
  39. package/src/language/locale/it.json +18 -0
  40. package/src/language/locale/jp.json +18 -0
  41. package/src/language/locale/ko.json +18 -0
  42. package/src/language/locale/nl.json +18 -0
  43. package/src/language/locale/nn.json +18 -0
  44. package/src/language/locale/no.json +18 -0
  45. package/src/language/locale/pl.json +18 -0
  46. package/src/language/locale/pt.json +18 -0
  47. package/src/language/locale/ru.json +18 -0
  48. package/src/language/locale/sk.json +18 -0
  49. package/src/language/locale/sr.json +17 -0
  50. package/src/language/locale/sv.json +18 -0
  51. package/src/language/locale/tr.json +18 -0
  52. package/src/language/locale/uk.json +18 -0
  53. package/src/language/locale/ur.json +18 -0
  54. package/src/language/locale/zh-cn.json +18 -0
  55. package/src/language/locale/zh-tw.json +18 -0
  56. package/src/main.ts +51 -0
  57. package/src/map/Map.ts +717 -0
  58. package/src/map/MapMarker.ts +149 -0
  59. package/src/map/openlayers/Map.OpenLayers.ts +1879 -0
  60. package/src/map/openlayers/MapMarker.OpenLayers.ts +176 -0
  61. package/src/map/openlayers/zoomifyTiles.ts +28 -0
  62. package/src/map/types.ts +17 -0
  63. package/src/media/EmbedUtil.ts +168 -0
  64. package/src/media/Media.ts +409 -0
  65. package/src/media/MediaType.ts +163 -0
  66. package/src/media/types/Audio.ts +87 -0
  67. package/src/media/types/Blockquote.ts +40 -0
  68. package/src/media/types/DailyMotion.ts +58 -0
  69. package/src/media/types/DocumentCloud.ts +41 -0
  70. package/src/media/types/Facebook.ts +41 -0
  71. package/src/media/types/Flickr.ts +115 -0
  72. package/src/media/types/GoogleDoc.ts +59 -0
  73. package/src/media/types/IFrame.ts +51 -0
  74. package/src/media/types/Image.ts +49 -0
  75. package/src/media/types/Juxtapose.ts +32 -0
  76. package/src/media/types/SoundCloud.ts +77 -0
  77. package/src/media/types/Text.ts +172 -0
  78. package/src/media/types/Twitter.ts +96 -0
  79. package/src/media/types/Video.ts +84 -0
  80. package/src/media/types/Vimeo.ts +65 -0
  81. package/src/media/types/Website.ts +36 -0
  82. package/src/media/types/Wikipedia.ts +124 -0
  83. package/src/media/types/YouTube.ts +192 -0
  84. package/src/scss/Typography.scss +237 -0
  85. package/src/scss/VCO.StoryMap.Dark.scss +138 -0
  86. package/src/scss/VCO.StoryMap.scss +164 -0
  87. package/src/scss/Variables.Dark.scss +56 -0
  88. package/src/scss/Variables.scss +47 -0
  89. package/src/scss/core/Mixins.scss +112 -0
  90. package/src/scss/core/Reset.scss +206 -0
  91. package/src/scss/fonts/_font.base.scss +113 -0
  92. package/src/scss/fonts/font.abril-droidsans.scss +75 -0
  93. package/src/scss/fonts/font.amatic-andika.scss +73 -0
  94. package/src/scss/fonts/font.bitter-raleway.scss +86 -0
  95. package/src/scss/fonts/font.clicker-garamond.scss +92 -0
  96. package/src/scss/fonts/font.dancing-ledger.scss +74 -0
  97. package/src/scss/fonts/font.default.scss +9 -0
  98. package/src/scss/fonts/font.fjalla-average.scss +80 -0
  99. package/src/scss/fonts/font.georgia-helvetica.scss +58 -0
  100. package/src/scss/fonts/font.knightlab.scss +97 -0
  101. package/src/scss/fonts/font.lustria-lato.scss +80 -0
  102. package/src/scss/fonts/font.medula-lato.scss +73 -0
  103. package/src/scss/fonts/font.oldstandard.scss +88 -0
  104. package/src/scss/fonts/font.opensans-gentiumbook.scss +80 -0
  105. package/src/scss/fonts/font.playfair-faunaone.scss +86 -0
  106. package/src/scss/fonts/font.playfair.scss +85 -0
  107. package/src/scss/fonts/font.pt.scss +90 -0
  108. package/src/scss/fonts/font.roboto-megrim.scss +73 -0
  109. package/src/scss/fonts/font.rufina-sintony.scss +73 -0
  110. package/src/scss/fonts/font.ubuntu.scss +78 -0
  111. package/src/scss/fonts/font.unicaone-vollkorn.scss +85 -0
  112. package/src/scss/icons/Icons.scss +239 -0
  113. package/src/scss/map/VCO.ImageMarker.scss +23 -0
  114. package/src/scss/map/VCO.Map.scss +21 -0
  115. package/src/scss/map/VCO.MapMarker.scss +147 -0
  116. package/src/scss/map/openlayers/VCO.Map.OpenLayers.scss +126 -0
  117. package/src/scss/media/VCO.Media.scss +222 -0
  118. package/src/scss/media/types/VCO.Media.Blockquote.scss +76 -0
  119. package/src/scss/media/types/VCO.Media.IFrame.scss +11 -0
  120. package/src/scss/media/types/VCO.Media.Image.scss +13 -0
  121. package/src/scss/media/types/VCO.Media.Instagram.scss +7 -0
  122. package/src/scss/media/types/VCO.Media.Profile.scss +5 -0
  123. package/src/scss/media/types/VCO.Media.Text.scss +90 -0
  124. package/src/scss/media/types/VCO.Media.Twitter.scss +87 -0
  125. package/src/scss/media/types/VCO.Media.Wikipedia.scss +64 -0
  126. package/src/scss/site/site.scss +748 -0
  127. package/src/scss/slider/VCO.Slide.scss +447 -0
  128. package/src/scss/slider/VCO.SlideNav.scss +338 -0
  129. package/src/scss/slider/VCO.StorySlider.scss +64 -0
  130. package/src/scss/snapmap/VCO.SnapMap.scss +103 -0
  131. package/src/scss/ui/VCO.Consent.scss +77 -0
  132. package/src/scss/ui/VCO.MenuBar.Button.scss +99 -0
  133. package/src/scss/ui/VCO.MenuBar.scss +20 -0
  134. package/src/scss/ui/VCO.Message.scss +104 -0
  135. package/src/site/site.ts +87 -0
  136. package/src/slider/Slide.ts +460 -0
  137. package/src/slider/SlideNav.ts +212 -0
  138. package/src/slider/StorySlider.ts +722 -0
  139. package/src/storymap/Consent.ts +146 -0
  140. package/src/storymap/StoryMap.ts +1108 -0
  141. package/src/storymap/iiif.ts +386 -0
  142. package/src/storymap/validate.ts +184 -0
  143. package/src/types.ts +297 -0
  144. package/src/ui/Draggable.ts +374 -0
  145. package/src/ui/MenuBar.ts +323 -0
  146. package/src/ui/Message.ts +118 -0
  147. package/src/ui/Swipable.ts +388 -0
  148. package/dist/assets/main-DwbXrrYn.js +0 -17
@@ -0,0 +1,388 @@
1
+ import Animate from "morpheus";
2
+ import { easeInOutQuint, easeOutStrong } from "../animation/easings";
3
+ import { Browser } from "../core/Browser";
4
+ import { Evented, type EventedInstance } from "../core/mixins";
5
+ import { mergeData } from "../core/Util";
6
+ import { DomEvent, type LegacyEvent } from "../dom/DomEvent";
7
+ import type { AnimateOptions, AnimationHandle } from "../types";
8
+
9
+ /* Swipable
10
+ Draggable allows you to add dragging capabilities to any element. Supports mobile devices too.
11
+ TODO Enable constraints
12
+ ================================================== */
13
+
14
+ interface DragEventNames {
15
+ down: string;
16
+ up: string;
17
+ leave: string;
18
+ move: string;
19
+ }
20
+
21
+ interface SwipableOptions {
22
+ snap: boolean;
23
+ enable: { x: boolean; y: boolean };
24
+ constraint: {
25
+ top: number | boolean;
26
+ bottom: number | boolean;
27
+ left: number | boolean;
28
+ right: number | boolean;
29
+ };
30
+ momentum_multiplier: number;
31
+ duration: number;
32
+ ease: unknown;
33
+ }
34
+
35
+ interface DragData {
36
+ sliding: boolean;
37
+ direction: string | null;
38
+ pagex: { start: number; end: number };
39
+ pagey: { start: number; end: number };
40
+ pos: { start: { x: number; y: number }; end: { x: number; y: number } };
41
+ new_pos: { x: number; y: number };
42
+ new_pos_parent: { x: number; y: number };
43
+ time: { start: number; end: number };
44
+ touch: boolean;
45
+ }
46
+
47
+ class SwipableBase {
48
+ declare "mousedrag": DragEventNames;
49
+ declare "touchdrag": DragEventNames;
50
+ declare "_el": Record<string, HTMLElement>;
51
+ declare "options": SwipableOptions;
52
+ declare "animator": AnimationHandle | null;
53
+ declare "dragevent": DragEventNames;
54
+ declare "data": DragData;
55
+ declare "fire": EventedInstance["fire"];
56
+
57
+ //_el: {},
58
+
59
+ constructor(
60
+ drag_elem: HTMLElement,
61
+ move_elem?: HTMLElement,
62
+ options?: Record<string, unknown>,
63
+ ) {
64
+ this.mousedrag = {
65
+ down: "mousedown",
66
+ up: "mouseup",
67
+ leave: "mouseleave",
68
+ move: "mousemove",
69
+ };
70
+ this.touchdrag = {
71
+ down: "touchstart",
72
+ up: "touchend",
73
+ leave: "mouseleave",
74
+ move: "touchmove",
75
+ };
76
+ // DOM ELements
77
+ this._el = {
78
+ drag: drag_elem,
79
+ move: drag_elem,
80
+ };
81
+ if (move_elem) {
82
+ this._el.move = move_elem;
83
+ }
84
+ //Options
85
+ this.options = {
86
+ snap: false,
87
+ enable: {
88
+ x: true,
89
+ y: true,
90
+ },
91
+ constraint: {
92
+ top: false,
93
+ bottom: false,
94
+ left: 0,
95
+ right: false,
96
+ },
97
+ momentum_multiplier: 2000,
98
+ duration: 1000,
99
+ ease: easeInOutQuint,
100
+ };
101
+ // Animation Object
102
+ this.animator = null;
103
+ // Drag Event Type
104
+ this.dragevent = this.mousedrag;
105
+ if (Browser.touch) {
106
+ this.dragevent = this.touchdrag;
107
+ }
108
+ // Draggable Data
109
+ this.data = {
110
+ sliding: false,
111
+ direction: "none",
112
+ pagex: {
113
+ start: 0,
114
+ end: 0,
115
+ },
116
+ pagey: {
117
+ start: 0,
118
+ end: 0,
119
+ },
120
+ pos: {
121
+ start: {
122
+ x: 0,
123
+ y: 0,
124
+ },
125
+ end: {
126
+ x: 0,
127
+ y: 0,
128
+ },
129
+ },
130
+ new_pos: {
131
+ x: 0,
132
+ y: 0,
133
+ },
134
+ new_pos_parent: {
135
+ x: 0,
136
+ y: 0,
137
+ },
138
+ time: {
139
+ start: 0,
140
+ end: 0,
141
+ },
142
+ touch: false,
143
+ };
144
+ // Merge Data and Options
145
+ mergeData(this.options, options);
146
+ }
147
+
148
+ enable(e?: LegacyEvent): void {
149
+ DomEvent.addListener(this._el.drag, this.dragevent.down, this._onDragStart, this);
150
+ DomEvent.addListener(this._el.drag, this.dragevent.up, this._onDragEnd, this);
151
+ this.data.pos.start = 0 as unknown as { x: number; y: number }; //VCO.Dom.getPosition(this._el.move);
152
+ this._el.move.style.left = this.data.pos.start.x + "px";
153
+ this._el.move.style.top = this.data.pos.start.y + "px";
154
+ this._el.move.style.position = "absolute";
155
+ //this._el.move.style.zIndex = "11";
156
+ //this._el.move.style.cursor = "move";
157
+ }
158
+
159
+ disable() {
160
+ DomEvent.removeListener(this._el.drag, this.dragevent.down, this._onDragStart, this);
161
+ DomEvent.removeListener(this._el.drag, this.dragevent.up, this._onDragEnd, this);
162
+ }
163
+
164
+ stopMomentum() {
165
+ if (this.animator) {
166
+ this.animator.stop();
167
+ }
168
+ }
169
+
170
+ updateConstraint(c: SwipableOptions["constraint"]): void {
171
+ this.options.constraint = c;
172
+ // Temporary until issues are fixed
173
+ }
174
+
175
+ /* Private Methods
176
+ ================================================== */
177
+ _onDragStart(e: LegacyEvent) {
178
+ if (this.animator) {
179
+ this.animator.stop();
180
+ }
181
+ if (Browser.touch) {
182
+ if (e.originalEvent) {
183
+ this.data.pagex.start = e.originalEvent.touches[0].screenX;
184
+ this.data.pagey.start = e.originalEvent.touches[0].screenY;
185
+ } else {
186
+ this.data.pagex.start = e.targetTouches[0].screenX;
187
+ this.data.pagey.start = e.targetTouches[0].screenY;
188
+ }
189
+ } else {
190
+ this.data.pagex.start = e.pageX;
191
+ this.data.pagey.start = e.pageY;
192
+ }
193
+ // Center element to finger or mouse
194
+ if (this.options.enable.x) {
195
+ //this._el.move.style.left = this.data.pagex.start - (this._el.move.offsetWidth / 2) + "px";
196
+ }
197
+ if (this.options.enable.y) {
198
+ //this._el.move.style.top = this.data.pagey.start - (this._el.move.offsetHeight / 2) + "px";
199
+ }
200
+ this.data.pos.start = { x: this._el.move.offsetLeft, y: this._el.move.offsetTop };
201
+ this.data.time.start = Date.now();
202
+ this.fire("dragstart", this.data);
203
+ DomEvent.addListener(this._el.drag, this.dragevent.move, this._onDragMove, this);
204
+ DomEvent.addListener(this._el.drag, this.dragevent.leave, this._onDragEnd, this);
205
+ }
206
+
207
+ _onDragEnd(e: LegacyEvent) {
208
+ this.data.sliding = false;
209
+ DomEvent.removeListener(this._el.drag, this.dragevent.move, this._onDragMove, this);
210
+ DomEvent.removeListener(this._el.drag, this.dragevent.leave, this._onDragEnd, this);
211
+ this.fire("dragend", this.data);
212
+ this._momentum();
213
+ }
214
+
215
+ _onDragMove(e: LegacyEvent) {
216
+ const change = {
217
+ x: 0,
218
+ y: 0,
219
+ };
220
+ //e.preventDefault();
221
+ this.data.sliding = true;
222
+ if (Browser.touch) {
223
+ if (e.originalEvent) {
224
+ this.data.pagex.end = e.originalEvent.touches[0].screenX;
225
+ this.data.pagey.end = e.originalEvent.touches[0].screenY;
226
+ } else {
227
+ this.data.pagex.end = e.targetTouches[0].screenX;
228
+ this.data.pagey.end = e.targetTouches[0].screenY;
229
+ }
230
+ } else {
231
+ this.data.pagex.end = e.pageX;
232
+ this.data.pagey.end = e.pageY;
233
+ }
234
+ change.x = this.data.pagex.start - this.data.pagex.end;
235
+ change.y = this.data.pagey.start - this.data.pagey.end;
236
+ this.data.pos.end = { x: this._el.drag.offsetLeft, y: this._el.drag.offsetTop };
237
+ this.data.new_pos.x = -(change.x - this.data.pos.start.x);
238
+ this.data.new_pos.y = -(change.y - this.data.pos.start.y);
239
+ if (this.options.enable.x && Math.abs(change.x) > Math.abs(change.y)) {
240
+ e.preventDefault();
241
+ this._el.move.style.left = this.data.new_pos.x + "px";
242
+ }
243
+ if (this.options.enable.y && Math.abs(change.y) > Math.abs(change.x)) {
244
+ e.preventDefault();
245
+ this._el.move.style.top = this.data.new_pos.y + "px";
246
+ }
247
+ this.fire("dragmove", this.data);
248
+ }
249
+
250
+ _momentum() {
251
+ const pos_adjust = {
252
+ x: 0,
253
+ y: 0,
254
+ time: 0,
255
+ },
256
+ pos_change = {
257
+ x: 0,
258
+ y: 0,
259
+ time: 0,
260
+ },
261
+ swipe_detect = {
262
+ x: false,
263
+ y: false,
264
+ };
265
+ let swipe = false;
266
+ const _swipe_direction = "";
267
+ this.data.direction = null;
268
+ pos_adjust.time = (Date.now() - this.data.time.start) * 10;
269
+ pos_change.time = (Date.now() - this.data.time.start) * 10;
270
+ pos_change.x =
271
+ this.options.momentum_multiplier *
272
+ (Math.abs(this.data.pagex.end) - Math.abs(this.data.pagex.start));
273
+ pos_change.y =
274
+ this.options.momentum_multiplier *
275
+ (Math.abs(this.data.pagey.end) - Math.abs(this.data.pagey.start));
276
+ pos_adjust.x = Math.round(pos_change.x / pos_change.time);
277
+ pos_adjust.y = Math.round(pos_change.y / pos_change.time);
278
+ this.data.new_pos.x = this.data.pos.end.x + pos_adjust.x;
279
+ this.data.new_pos.y = this.data.pos.end.y + pos_adjust.y;
280
+ if (!this.options.enable.x) {
281
+ this.data.new_pos.x = this.data.pos.start.x;
282
+ } else if (this.data.new_pos.x > 0) {
283
+ this.data.new_pos.x = 0;
284
+ }
285
+ if (!this.options.enable.y) {
286
+ this.data.new_pos.y = this.data.pos.start.y;
287
+ } else if (this.data.new_pos.y < 0) {
288
+ this.data.new_pos.y = 0;
289
+ }
290
+ // Detect Swipe
291
+ if (pos_change.time < 2000) {
292
+ swipe = true;
293
+ }
294
+ if (this.options.enable.x && this.options.enable.y) {
295
+ if (Math.abs(pos_change.x) > Math.abs(pos_change.y)) {
296
+ swipe_detect.x = true;
297
+ } else {
298
+ swipe_detect.y = true;
299
+ }
300
+ } else if (this.options.enable.x) {
301
+ if (Math.abs(pos_change.x) > Math.abs(pos_change.y)) {
302
+ swipe_detect.x = true;
303
+ }
304
+ } else {
305
+ if (Math.abs(pos_change.y) > Math.abs(pos_change.x)) {
306
+ swipe_detect.y = true;
307
+ }
308
+ }
309
+ // Detect Direction and long swipe
310
+ if (swipe_detect.x) {
311
+ // Long Swipe
312
+ if (Math.abs(pos_change.x) > this._el.drag.offsetWidth / 2) {
313
+ swipe = true;
314
+ }
315
+ if (Math.abs(pos_change.x) > 10000) {
316
+ this.data.direction = "left";
317
+ if (pos_change.x > 0) {
318
+ this.data.direction = "right";
319
+ }
320
+ }
321
+ }
322
+ if (swipe_detect.y) {
323
+ // Long Swipe
324
+ if (Math.abs(pos_change.y) > this._el.drag.offsetHeight / 2) {
325
+ swipe = true;
326
+ }
327
+ if (Math.abs(pos_change.y) > 10000) {
328
+ this.data.direction = "up";
329
+ if (pos_change.y > 0) {
330
+ this.data.direction = "down";
331
+ }
332
+ }
333
+ }
334
+ this._animateMomentum();
335
+ if (swipe && this.data.direction) {
336
+ this.fire("swipe_" + this.data.direction, this.data);
337
+ } else if (this.data.direction) {
338
+ this.fire("swipe_nodirection", this.data);
339
+ } else if (this.options.snap) {
340
+ this.animator.stop();
341
+ this.animator = Animate(this._el.move, {
342
+ top: this.data.pos.start.y,
343
+ left: this.data.pos.start.x,
344
+ duration: this.options.duration,
345
+ easing: easeOutStrong,
346
+ });
347
+ }
348
+ }
349
+
350
+ _animateMomentum() {
351
+ const pos = {
352
+ x: this.data.new_pos.x,
353
+ y: this.data.new_pos.y,
354
+ },
355
+ animate: AnimateOptions = {
356
+ duration: this.options.duration,
357
+ easing: easeOutStrong,
358
+ };
359
+ if (this.options.enable.y) {
360
+ if (this.options.constraint.top || this.options.constraint.bottom) {
361
+ if (pos.y > (this.options.constraint.bottom as number)) {
362
+ pos.y = this.options.constraint.bottom as number;
363
+ } else if (pos.y < (this.options.constraint.top as number)) {
364
+ pos.y = this.options.constraint.top as number;
365
+ }
366
+ }
367
+ animate.top = Math.floor(pos.y) + "px";
368
+ }
369
+ if (this.options.enable.x) {
370
+ if (this.options.constraint.left || this.options.constraint.right) {
371
+ if (pos.x >= (this.options.constraint.left as number)) {
372
+ pos.x = this.options.constraint.left as number;
373
+ } else if (pos.x < (this.options.constraint.right as number)) {
374
+ pos.x = this.options.constraint.right as number;
375
+ }
376
+ }
377
+ animate.left = Math.floor(pos.x) + "px";
378
+ }
379
+ this.animator = Animate(this._el.move, animate);
380
+ this.fire("momentum", this.data);
381
+ }
382
+ }
383
+
384
+ export default class Swipable extends Evented(SwipableBase) {
385
+ constructor(...args: ConstructorParameters<typeof SwipableBase>) {
386
+ super(...args);
387
+ }
388
+ }