2018-04-12 04:05:30 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2019-07-18 08:30:28 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
2017-07-01 03:16:00 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2023-03-02 21:25:08 +08:00
|
|
|
import { throttle } from '/imports/utils/throttle';
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
const PAN_ZOOM_INTERVAL = Meteor.settings.public.presentation.panZoomInterval || 200;
|
|
|
|
|
|
|
|
const getNumberOfSlides = (podId, presentationId) => {
|
2018-04-12 04:05:30 +08:00
|
|
|
const meetingId = Auth.meetingID;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
const presentation = Presentations.findOne({
|
2017-06-03 03:25:02 +08:00
|
|
|
meetingId,
|
2018-04-12 04:05:30 +08:00
|
|
|
podId,
|
2019-07-18 08:30:28 +08:00
|
|
|
id: presentationId,
|
|
|
|
});
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2021-11-30 19:45:57 +08:00
|
|
|
return presentation && presentation.pages ? presentation.pages.length : 0;
|
2016-08-03 06:55:20 +08:00
|
|
|
};
|
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const previousSlide = (currentSlideNum, podId) => {
|
2016-08-06 02:39:24 +08:00
|
|
|
if (currentSlideNum > 1) {
|
2018-04-12 04:05:30 +08:00
|
|
|
makeCall('switchSlide', currentSlideNum - 1, podId);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const nextSlide = (currentSlideNum, numberOfSlides, podId) => {
|
2016-08-06 02:39:24 +08:00
|
|
|
if (currentSlideNum < numberOfSlides) {
|
2018-04-12 04:05:30 +08:00
|
|
|
makeCall('switchSlide', currentSlideNum + 1, podId);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-16 20:12:43 +08:00
|
|
|
const zoomSlide = throttle((currentSlideNum, podId, widthRatio, heightRatio, xOffset, yOffset) => {
|
|
|
|
makeCall('zoomSlide', currentSlideNum, podId, widthRatio, heightRatio, xOffset, yOffset);
|
2019-07-18 08:30:28 +08:00
|
|
|
}, PAN_ZOOM_INTERVAL);
|
2018-08-14 03:29:38 +08:00
|
|
|
|
2018-04-12 04:05:30 +08:00
|
|
|
const skipToSlide = (requestedSlideNum, podId) => {
|
|
|
|
makeCall('switchSlide', requestedSlideNum, podId);
|
2016-08-06 02:39:24 +08:00
|
|
|
};
|
|
|
|
|
2016-08-03 06:55:20 +08:00
|
|
|
export default {
|
2019-07-18 08:30:28 +08:00
|
|
|
getNumberOfSlides,
|
2016-08-06 02:39:24 +08:00
|
|
|
nextSlide,
|
|
|
|
previousSlide,
|
|
|
|
skipToSlide,
|
2018-08-14 03:29:38 +08:00
|
|
|
zoomSlide,
|
2016-08-03 06:55:20 +08:00
|
|
|
};
|