@netless/app-presentation 0.1.8 → 0.1.9-beta.0
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.
- package/dist/index.d.ts +4 -0
- package/dist/index.global.js +265 -17
- package/dist/index.js +265 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +42 -19
- package/src/scrollbar/Draggable.ts +79 -0
- package/src/scrollbar/index.ts +205 -0
- package/src/scrollbar/style.scss +53 -0
- package/src/style.scss +51 -0
package/dist/index.d.ts
CHANGED
|
@@ -334,6 +334,10 @@ interface PresentationAppOptions {
|
|
|
334
334
|
viewport?: Viewport | ((page: PresentationPage) => Viewport);
|
|
335
335
|
/** justDocsViewReadonly is used to set the presentation readonly, it will be used in the presentation, and the presentation will be readonly when the app is initialized */
|
|
336
336
|
justDocsViewReadonly?: true;
|
|
337
|
+
/** useScrollbar is used to set the presentation use scrollbar, it will be used in the presentation, and the presentation will be use scrollbar when the app is initialized */
|
|
338
|
+
useScrollbar?: boolean;
|
|
339
|
+
/** debounceSync is used to set the presentation debounce sync, it will be used in the presentation, and the presentation will be debounce sync when the app is initialized */
|
|
340
|
+
debounceSync?: boolean;
|
|
337
341
|
}
|
|
338
342
|
interface PresentationController {
|
|
339
343
|
readonly app: Presentation;
|
package/dist/index.global.js
CHANGED
|
@@ -1156,7 +1156,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1156
1156
|
};
|
|
1157
1157
|
|
|
1158
1158
|
// src/style.scss?inline
|
|
1159
|
-
var style_default = ".netless-app-presentation{height:100%;display:flex;flex-flow:column nowrap}.netless-app-presentation-content{position:relative;height:100%;overflow:hidden}.netless-app-presentation-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-presentation-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:#ededf0e6;box-shadow:inset -1px 0 #0000001c;transition:transform .4s;overflow:auto;overflow-y:scroll}.netless-app-presentation-preview-active .netless-app-presentation-preview-mask{display:block}.netless-app-presentation-preview-active .netless-app-presentation-preview{transform:translate(0)}.netless-app-presentation-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:#0000;outline:none;border:7px solid rgba(0,0,0,0);border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-presentation-preview-page:hover,.netless-app-presentation-preview-page.netless-app-presentation-preview-page-active{border-color:#444e601a}.netless-app-presentation-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-presentation-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-presentation-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-presentation-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:#f9f9fce6;transition:opacity .4s}.netless-app-presentation-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:#0000;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-footer-btn:hover{background:#ededf0e6}@media (hover: none){.netless-app-presentation-footer-btn:hover{background:#0000!important}}.netless-app-presentation-footer-btn>svg{width:100%;height:100%}.netless-app-presentation-footer-btn>svg:nth-of-type(2){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-presentation-footer-btn~.netless-app-presentation-footer-btn{margin-left:15px}.netless-app-presentation-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-presentation-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-presentation-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:#0000;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-page-number-input:hover,.netless-app-presentation-page-number-input:focus,.netless-app-presentation-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-presentation-readonly.netless-app-presentation-footer{display:none}.netless-app-presentation-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden;transition:opacity .2s}.netless-app-presentation-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.netless-app-presentation-image>img{max-width:100%;max-height:100%;object-fit:contain}.telebox-color-scheme-dark .netless-app-presentation-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-presentation-page-number-input:active,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:focus,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-presentation-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-presentation-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-presentation-preview{background:#323232e6}";
|
|
1159
|
+
var style_default = ".netless-app-presentation{height:100%;display:flex;flex-flow:column nowrap}.netless-app-presentation-content{position:relative;height:100%;overflow:hidden}.netless-app-presentation-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-presentation-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:#ededf0e6;box-shadow:inset -1px 0 #0000001c;transition:transform .4s;overflow:auto;overflow-y:scroll}.netless-app-presentation-preview-active .netless-app-presentation-preview-mask{display:block}.netless-app-presentation-preview-active .netless-app-presentation-preview{transform:translate(0)}.netless-app-presentation-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:#0000;outline:none;border:7px solid rgba(0,0,0,0);border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-presentation-preview-page:hover,.netless-app-presentation-preview-page.netless-app-presentation-preview-page-active{border-color:#444e601a}.netless-app-presentation-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-presentation-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-presentation-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-presentation-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:#f9f9fce6;transition:opacity .4s}.netless-app-presentation-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:#0000;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-footer-btn:hover{background:#ededf0e6}@media (hover: none){.netless-app-presentation-footer-btn:hover{background:#0000!important}}.netless-app-presentation-footer-btn>svg{width:100%;height:100%}.netless-app-presentation-footer-btn>svg:nth-of-type(2){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-presentation-footer-btn~.netless-app-presentation-footer-btn{margin-left:15px}.netless-app-presentation-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-presentation-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-presentation-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:#0000;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-page-number-input:hover,.netless-app-presentation-page-number-input:focus,.netless-app-presentation-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-presentation-readonly.netless-app-presentation-footer{display:none}.netless-app-presentation-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden;transition:opacity .2s}.netless-app-presentation-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.netless-app-presentation-image>img{max-width:100%;max-height:100%;object-fit:contain}.telebox-color-scheme-dark .netless-app-presentation-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-presentation-page-number-input:active,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:focus,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-presentation-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-presentation-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-presentation-preview{background:#323232e6}.netless-app-presentation-scrollbar-container{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;z-index:101}.netless-app-presentation-scrollbar-container-x,.netless-app-presentation-scrollbar-container-y{position:absolute;pointer-events:none;display:flex;justify-content:center;box-sizing:border-box;padding:0}.netless-app-presentation-scrollbar-container-x{bottom:0;left:0;height:6px;width:100%;padding-right:6px}.netless-app-presentation-scrollbar-container-y{top:0;right:0;width:6px;height:100%;flex-direction:column;padding-bottom:6px}.netless-app-presentation-scrollbar-x,.netless-app-presentation-scrollbar-y{border-radius:2px;background-color:#1b1f4d4d;pointer-events:auto;cursor:default}.netless-app-presentation-scrollbar-x{height:6px}.netless-app-presentation-scrollbar-y{width:6px}";
|
|
1160
1160
|
|
|
1161
1161
|
// src/store.ts
|
|
1162
1162
|
function noop() {
|
|
@@ -1227,6 +1227,235 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1227
1227
|
};
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
+
// src/scrollbar/Draggable.ts
|
|
1231
|
+
function makeDraggable(element, options) {
|
|
1232
|
+
let currentDragger = null;
|
|
1233
|
+
let originalMouseX = 0;
|
|
1234
|
+
let originalMouseY = 0;
|
|
1235
|
+
const { onDragEnd, onDrag, onDragStart, direction = "xy" } = options;
|
|
1236
|
+
const drag = (e, state) => {
|
|
1237
|
+
e.stopPropagation();
|
|
1238
|
+
if (!currentDragger)
|
|
1239
|
+
return;
|
|
1240
|
+
let transformedDragX = 0;
|
|
1241
|
+
let transformedDragY = 0;
|
|
1242
|
+
if (direction === "x") {
|
|
1243
|
+
transformedDragX = Math.round(e.pageX - originalMouseX);
|
|
1244
|
+
} else if (direction === "y") {
|
|
1245
|
+
transformedDragY = Math.round(e.pageY - originalMouseY);
|
|
1246
|
+
} else {
|
|
1247
|
+
transformedDragX = Math.round(e.pageX - originalMouseX);
|
|
1248
|
+
transformedDragY = Math.round(e.pageY - originalMouseY);
|
|
1249
|
+
}
|
|
1250
|
+
if (state === 3 /* END */) {
|
|
1251
|
+
onDragEnd == null ? void 0 : onDragEnd({ x: transformedDragX, y: transformedDragY });
|
|
1252
|
+
} else {
|
|
1253
|
+
onDrag == null ? void 0 : onDrag({ x: transformedDragX, y: transformedDragY });
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
element.addEventListener("pointerdown", bindDrag);
|
|
1257
|
+
function bindDrag(e) {
|
|
1258
|
+
currentDragger = e.target;
|
|
1259
|
+
e.stopPropagation();
|
|
1260
|
+
if (currentDragger !== element) {
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
originalMouseX = e.pageX;
|
|
1264
|
+
originalMouseY = e.pageY;
|
|
1265
|
+
element.addEventListener("pointermove", drag);
|
|
1266
|
+
document.body.addEventListener("pointerup", stopDrag);
|
|
1267
|
+
element.setPointerCapture(e.pointerId);
|
|
1268
|
+
onDragStart == null ? void 0 : onDragStart();
|
|
1269
|
+
}
|
|
1270
|
+
function removeEventListener2() {
|
|
1271
|
+
currentDragger = null;
|
|
1272
|
+
element.removeEventListener("pointermove", drag);
|
|
1273
|
+
document.body.removeEventListener("pointerup", stopDrag);
|
|
1274
|
+
}
|
|
1275
|
+
function stopDrag(e) {
|
|
1276
|
+
if (!currentDragger)
|
|
1277
|
+
return;
|
|
1278
|
+
e.stopPropagation();
|
|
1279
|
+
drag(e, 3 /* END */);
|
|
1280
|
+
removeEventListener2();
|
|
1281
|
+
}
|
|
1282
|
+
function destroy() {
|
|
1283
|
+
stop();
|
|
1284
|
+
element.removeEventListener("pointerdown", bindDrag);
|
|
1285
|
+
}
|
|
1286
|
+
function stop() {
|
|
1287
|
+
removeEventListener2();
|
|
1288
|
+
}
|
|
1289
|
+
return { destroy };
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// src/scrollbar/index.ts
|
|
1293
|
+
var Scrollbar = class {
|
|
1294
|
+
constructor(container, option, view) {
|
|
1295
|
+
this.namespace = "netless-app-presentation";
|
|
1296
|
+
this.scrollContainer = document.createElement("div");
|
|
1297
|
+
this.option = {
|
|
1298
|
+
getPageSize: () => {
|
|
1299
|
+
return {
|
|
1300
|
+
width: 0,
|
|
1301
|
+
height: 0
|
|
1302
|
+
};
|
|
1303
|
+
},
|
|
1304
|
+
getWritable: () => false,
|
|
1305
|
+
syncView: () => void 0
|
|
1306
|
+
};
|
|
1307
|
+
this.onCameraUpdated = () => {
|
|
1308
|
+
const { scale, centerX, centerY } = this.view.camera;
|
|
1309
|
+
const originScale = this.getOriginScale();
|
|
1310
|
+
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1311
|
+
const scrollX = Math.round(centerX * originScale);
|
|
1312
|
+
const scrollY = Math.round(centerY * originScale);
|
|
1313
|
+
if (this.scrollbarX) {
|
|
1314
|
+
this.scrollbarX.style.width = `${ratio * 100}%`;
|
|
1315
|
+
this.scrollbarX.style.display = ratio === 1 ? "none" : "block";
|
|
1316
|
+
this.scrollbarX.style.transform = `translateX(${scrollX}px)`;
|
|
1317
|
+
}
|
|
1318
|
+
if (this.scrollbarY) {
|
|
1319
|
+
this.scrollbarY.style.height = `${ratio * 100}%`;
|
|
1320
|
+
this.scrollbarY.style.display = ratio === 1 ? "none" : "block";
|
|
1321
|
+
this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
this.onDragStart = () => {
|
|
1325
|
+
const camera = this.view.camera;
|
|
1326
|
+
this.cameraCache = {
|
|
1327
|
+
centerX: camera.centerX,
|
|
1328
|
+
centerY: camera.centerY,
|
|
1329
|
+
scale: camera.scale
|
|
1330
|
+
};
|
|
1331
|
+
};
|
|
1332
|
+
this.onDragX = (transformedDrag) => {
|
|
1333
|
+
if (this.cameraCache) {
|
|
1334
|
+
const { x } = transformedDrag;
|
|
1335
|
+
const originScale = this.getOriginScale();
|
|
1336
|
+
const { minX, maxX } = this.getScrollXRange(this.cameraCache);
|
|
1337
|
+
const scrollX = Math.round(x / originScale);
|
|
1338
|
+
let centerX = scrollX + this.cameraCache.centerX;
|
|
1339
|
+
if (centerX < minX) {
|
|
1340
|
+
centerX = minX;
|
|
1341
|
+
} else if (centerX > maxX) {
|
|
1342
|
+
centerX = maxX;
|
|
1343
|
+
}
|
|
1344
|
+
this.view.moveCamera({
|
|
1345
|
+
centerX,
|
|
1346
|
+
animationMode: "immediately"
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
this.onDragY = (transformedDrag) => {
|
|
1351
|
+
if (this.cameraCache) {
|
|
1352
|
+
const { y } = transformedDrag;
|
|
1353
|
+
const originScale = this.getOriginScale();
|
|
1354
|
+
const { minY, maxY } = this.getScrollYRange(this.cameraCache);
|
|
1355
|
+
const scrollY = Math.round(y / originScale);
|
|
1356
|
+
let centerY = scrollY + this.cameraCache.centerY;
|
|
1357
|
+
if (centerY < minY) {
|
|
1358
|
+
centerY = minY;
|
|
1359
|
+
} else if (centerY > maxY) {
|
|
1360
|
+
centerY = maxY;
|
|
1361
|
+
}
|
|
1362
|
+
this.view.moveCamera({
|
|
1363
|
+
centerY,
|
|
1364
|
+
animationMode: "immediately"
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
this.onDragEnd = () => {
|
|
1369
|
+
this.cameraCache = void 0;
|
|
1370
|
+
this.option.syncView();
|
|
1371
|
+
};
|
|
1372
|
+
this.scrollContainer.className = this.c("scrollbar-container");
|
|
1373
|
+
this.container = container;
|
|
1374
|
+
this.option = option;
|
|
1375
|
+
this.view = view;
|
|
1376
|
+
this.init();
|
|
1377
|
+
this.view.callbacks.on("onCameraUpdated", this.onCameraUpdated);
|
|
1378
|
+
}
|
|
1379
|
+
c(className) {
|
|
1380
|
+
return `${this.namespace}-${className}`;
|
|
1381
|
+
}
|
|
1382
|
+
getOriginScale() {
|
|
1383
|
+
const { size } = this.view;
|
|
1384
|
+
const { width, height } = this.option.getPageSize();
|
|
1385
|
+
return Math.min(size.height / height, size.width / width);
|
|
1386
|
+
}
|
|
1387
|
+
getScrollXRange(camera) {
|
|
1388
|
+
const { width } = this.option.getPageSize();
|
|
1389
|
+
const originScale = this.getOriginScale();
|
|
1390
|
+
const scale = camera.scale;
|
|
1391
|
+
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1392
|
+
const scrollWidth = width * (1 - ratio);
|
|
1393
|
+
const minX = -scrollWidth / 2;
|
|
1394
|
+
const maxX = scrollWidth / 2;
|
|
1395
|
+
return { minX, maxX };
|
|
1396
|
+
}
|
|
1397
|
+
getScrollYRange(camera) {
|
|
1398
|
+
const { height } = this.option.getPageSize();
|
|
1399
|
+
const originScale = this.getOriginScale();
|
|
1400
|
+
const scale = camera.scale;
|
|
1401
|
+
const ratio = Math.round(originScale / scale * 1e3) / 1e3;
|
|
1402
|
+
const scrollHeight = height * (1 - ratio);
|
|
1403
|
+
const minY = -scrollHeight / 2;
|
|
1404
|
+
const maxY = scrollHeight / 2;
|
|
1405
|
+
return { minY, maxY };
|
|
1406
|
+
}
|
|
1407
|
+
init() {
|
|
1408
|
+
this.scrollbarX = document.createElement("div");
|
|
1409
|
+
this.scrollbarX.classList.add(this.c("scrollbar-x"));
|
|
1410
|
+
if (this.option.getWritable()) {
|
|
1411
|
+
this.draggableX = makeDraggable(this.scrollbarX, {
|
|
1412
|
+
direction: "x",
|
|
1413
|
+
onDrag: this.onDragX,
|
|
1414
|
+
onDragEnd: this.onDragEnd,
|
|
1415
|
+
onDragStart: this.onDragStart
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
Object.assign(this.scrollbarX.style, {
|
|
1419
|
+
width: "100%",
|
|
1420
|
+
display: "none"
|
|
1421
|
+
});
|
|
1422
|
+
this.scrollbarContainerX = document.createElement("div");
|
|
1423
|
+
this.scrollbarContainerX.classList.add(this.c("scrollbar-container-x"));
|
|
1424
|
+
this.scrollbarContainerX.appendChild(this.scrollbarX);
|
|
1425
|
+
this.scrollbarY = document.createElement("div");
|
|
1426
|
+
this.scrollbarY.classList.add(this.c("scrollbar-y"));
|
|
1427
|
+
if (this.option.getWritable()) {
|
|
1428
|
+
this.draggableY = makeDraggable(this.scrollbarY, {
|
|
1429
|
+
direction: "y",
|
|
1430
|
+
onDrag: this.onDragY,
|
|
1431
|
+
onDragEnd: this.onDragEnd,
|
|
1432
|
+
onDragStart: this.onDragStart
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
Object.assign(this.scrollbarY.style, {
|
|
1436
|
+
height: "100%",
|
|
1437
|
+
display: "none"
|
|
1438
|
+
});
|
|
1439
|
+
this.scrollbarContainerY = document.createElement("div");
|
|
1440
|
+
this.scrollbarContainerY.classList.add(this.c("scrollbar-container-y"));
|
|
1441
|
+
this.scrollbarContainerY.appendChild(this.scrollbarY);
|
|
1442
|
+
this.scrollContainer.append(this.scrollbarContainerX, this.scrollbarContainerY);
|
|
1443
|
+
this.container.appendChild(this.scrollContainer);
|
|
1444
|
+
}
|
|
1445
|
+
destroy() {
|
|
1446
|
+
var _a, _b, _c, _d;
|
|
1447
|
+
this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
|
1448
|
+
(_a = this.scrollbarX) == null ? void 0 : _a.remove();
|
|
1449
|
+
(_b = this.scrollbarY) == null ? void 0 : _b.remove();
|
|
1450
|
+
this.scrollbarX = void 0;
|
|
1451
|
+
this.scrollbarY = void 0;
|
|
1452
|
+
(_c = this.draggableX) == null ? void 0 : _c.destroy();
|
|
1453
|
+
(_d = this.draggableY) == null ? void 0 : _d.destroy();
|
|
1454
|
+
this.draggableX = void 0;
|
|
1455
|
+
this.draggableY = void 0;
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1230
1459
|
// src/app-presentation.ts
|
|
1231
1460
|
var emptySceneName = "$$empty$$";
|
|
1232
1461
|
var ppt2page = (ppt, name) => ppt ? { width: ppt.width, height: ppt.height, src: ppt.src, thumbnail: ppt.previewURL, name } : null;
|
|
@@ -1418,21 +1647,27 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1418
1647
|
}
|
|
1419
1648
|
};
|
|
1420
1649
|
const syncView = () => {
|
|
1421
|
-
if (
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
if (width && height && context.getIsWritable()) {
|
|
1425
|
-
const { camera, size } = view;
|
|
1426
|
-
const fixedW = Math.min(size.width, size.height * width / height);
|
|
1427
|
-
const fixedH = Math.min(size.height, size.width * height / width);
|
|
1428
|
-
const w = fixedW / camera.scale;
|
|
1429
|
-
const h = fixedH / camera.scale;
|
|
1430
|
-
const x = camera.centerX - w / 2;
|
|
1431
|
-
const y = camera.centerY - h / 2;
|
|
1432
|
-
throttleSyncView = setTimeout(() => {
|
|
1650
|
+
if (context.getIsWritable()) {
|
|
1651
|
+
if (options.debounceSync) {
|
|
1652
|
+
clearTimeout(throttleSyncView);
|
|
1433
1653
|
throttleSyncView = 0;
|
|
1434
|
-
|
|
1435
|
-
|
|
1654
|
+
}
|
|
1655
|
+
if (throttleSyncView > 0)
|
|
1656
|
+
return;
|
|
1657
|
+
const { width, height } = app.page() || {};
|
|
1658
|
+
if (width && height) {
|
|
1659
|
+
throttleSyncView = setTimeout(() => {
|
|
1660
|
+
throttleSyncView = 0;
|
|
1661
|
+
const { camera, size } = view;
|
|
1662
|
+
const fixedW = Math.min(size.width, size.height * width / height);
|
|
1663
|
+
const fixedH = Math.min(size.height, size.width * height / width);
|
|
1664
|
+
const w = fixedW / camera.scale;
|
|
1665
|
+
const h = fixedH / camera.scale;
|
|
1666
|
+
const x = camera.centerX - w / 2;
|
|
1667
|
+
const y = camera.centerY - h / 2;
|
|
1668
|
+
view$$.setState({ uid: me, originX: x, originY: y, width: w, height: h });
|
|
1669
|
+
}, 50);
|
|
1670
|
+
}
|
|
1436
1671
|
}
|
|
1437
1672
|
};
|
|
1438
1673
|
dispose2.add(() => {
|
|
@@ -1454,7 +1689,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1454
1689
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
1455
1690
|
const box = context.getBox();
|
|
1456
1691
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
1457
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.
|
|
1692
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.0";
|
|
1458
1693
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
1459
1694
|
app.log = log;
|
|
1460
1695
|
if (options.justDocsViewReadonly) {
|
|
@@ -1489,6 +1724,19 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1489
1724
|
dispose2.add(context.emitter.on("writableChange", (isWritable) => {
|
|
1490
1725
|
app.setReadonly(!isWritable);
|
|
1491
1726
|
}));
|
|
1727
|
+
if (options.useScrollbar) {
|
|
1728
|
+
dispose2.make(() => {
|
|
1729
|
+
const scrollbar = new Scrollbar(app.contentDOM, {
|
|
1730
|
+
getPageSize: () => {
|
|
1731
|
+
const { width, height } = app.page() || {};
|
|
1732
|
+
return { width: width || 0, height: height || 0 };
|
|
1733
|
+
},
|
|
1734
|
+
getWritable: () => context.getIsWritable(),
|
|
1735
|
+
syncView: () => syncView()
|
|
1736
|
+
}, view);
|
|
1737
|
+
return () => scrollbar.destroy();
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1492
1740
|
context.emitter.on("destroy", () => dispose2());
|
|
1493
1741
|
const reportProgress = (progress, result) => {
|
|
1494
1742
|
window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
|
|
@@ -1662,7 +1910,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
1662
1910
|
};
|
|
1663
1911
|
|
|
1664
1912
|
// src/index.ts
|
|
1665
|
-
var version = "0.1.
|
|
1913
|
+
var version = "0.1.9-beta.0";
|
|
1666
1914
|
|
|
1667
1915
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
1668
1916
|
exports.Presentation = Presentation;
|