Improve performance of presentation to load slides faster

This commit is contained in:
Alex Lion
2024-12-30 20:20:48 -05:00
parent 3300bd210d
commit e66da3192d
5 changed files with 32 additions and 26 deletions

View File

@@ -1,3 +1,9 @@
### v.2.3.1
### Fixes and improvements
- Improve performance of presentation to load slides faster
### v.2.3.0
### Features

View File

@@ -5,6 +5,8 @@ export class Manager {
this.context = context;
this.currentPage = parseInt(context.el.dataset.currentPage);
this.maxPage = parseInt(context.el.dataset.maxPage);
localStorage.setItem("slide-position", this.currentPage);
}
init() {
@@ -31,19 +33,14 @@ export class Manager {
window.addEventListener("keydown", (e) => {
if ((e.target.tagName || "").toLowerCase() != "input") {
e.preventDefault();
switch (e.key) {
case "ArrowUp":
this.prevPage();
break;
case "ArrowLeft":
e.preventDefault();
this.prevPage();
break;
case "ArrowRight":
this.nextPage();
break;
case "ArrowDown":
e.preventDefault();
this.nextPage();
break;
}
@@ -168,6 +165,7 @@ export class Manager {
if (this.currentPage == this.maxPage - 1) return;
this.currentPage += 1;
localStorage.setItem("slide-position", this.currentPage);
this.context.pushEventTo(this.context.el, "current-page", {
page: this.currentPage.toString(),
});
@@ -177,6 +175,7 @@ export class Manager {
if (this.currentPage == 0) return;
this.currentPage -= 1;
localStorage.setItem("slide-position", this.currentPage);
this.context.pushEventTo(this.context.el, "current-page", {
page: this.currentPage.toString(),
});

View File

@@ -19,6 +19,7 @@ export class Presenter {
controls: false,
swipeAngle: false,
startIndex: this.currentPage,
speed: 0,
loop: false,
nav: false,
});
@@ -29,8 +30,13 @@ export class Presenter {
this.context.handleEvent("page", (data) => {
//set current page
if (this.currentPage == data.current_page) {
return;
}
this.currentPage = parseInt(data.current_page);
this.slider.goTo(data.current_page);
});
this.context.handleEvent("chat-visible", (data) => {
@@ -103,35 +109,37 @@ export class Presenter {
window.addEventListener("keyup", (e) => {
if (e.target.tagName.toLowerCase() != "input") {
e.preventDefault();
switch (e.key) {
case "f": // F
e.preventDefault();
this.fullscreen();
break;
case "ArrowUp":
window.opener.dispatchEvent(
new KeyboardEvent("keydown", { key: "ArrowUp" })
);
break;
case "ArrowLeft":
e.preventDefault();
window.opener.dispatchEvent(
new KeyboardEvent("keydown", { key: "ArrowLeft" })
);
break;
case "ArrowRight":
e.preventDefault();
window.opener.dispatchEvent(
new KeyboardEvent("keydown", { key: "ArrowRight" })
);
break;
case "ArrowDown":
window.opener.dispatchEvent(
new KeyboardEvent("keydown", { key: "ArrowDown" })
);
break;
}
}
});
window.addEventListener("storage", (e) => {
console.log(e)
if (e.key == "slide-position") {
console.log("settings new value " + Date.now())
this.currentPage = parseInt(e.newValue);
this.slider.goTo(e.newValue);
}
})
}
update() {

View File

@@ -27,13 +27,6 @@ defmodule ClaperWeb.EventLive.Presenter do
if connected?(socket) do
Claper.Events.Event.subscribe(event.uuid)
Claper.Presentations.subscribe(event.presentation_file.id)
Presence.track(
self(),
"event:#{event.uuid}",
socket.assigns.current_user.id,
%{}
)
end
endpoint_config = Application.get_env(:claper, ClaperWeb.Endpoint)[:url]

View File

@@ -1,7 +1,7 @@
defmodule Claper.MixProject do
use Mix.Project
@version "2.3.0"
@version "2.3.1"
def project do
[