Commit 975aaa2c authored by Curtis Adam's avatar Curtis Adam

Refactor the resizeFlashcard events

parent 9c19b54b
......@@ -117,10 +117,13 @@ export let CardNavigation = class CardNavigation {
static switchCard (updateLearningMode = 0, answeredCard = 0, answer = 0) {
let flashcardCarousel = $('#cardCarousel');
flashcardCarousel.on('slide.bs.carousel', function () {
CardVisuals.resizeFlashcard();
CardNavigation.toggleVisibility(false);
flashcardCarousel.off('slide.bs.carousel');
});
flashcardCarousel.on('slid.bs.carousel', function () {
$('.scrollLeft').removeClass('pressed');
$('.scrollRight').removeClass('pressed');
......@@ -133,6 +136,7 @@ export let CardNavigation = class CardNavigation {
}
setTimeout(function () {
CardNavigation.toggleVisibility(true);
flashcardCarousel.off('slid.bs.carousel');
}, 300);
});
}
......
......@@ -41,6 +41,7 @@ Template.flashcards.onCreated(function () {
});
let resizeInterval;
let windowResizeSensor;
Template.flashcards.onRendered(function () {
if (window.innerWidth <= 1400) {
if (Router.current().route.getName() === "cardsetdetailsid") {
......@@ -71,6 +72,9 @@ Template.flashcards.onRendered(function () {
new ResizeSensor($('#cardCarousel'), function () {
CardVisuals.resizeFlashcard();
});
windowResizeSensor = $(window).resize(function () {
CardVisuals.resizeFlashcard();
});
CardVisuals.resizeFlashcard();
CardVisuals.setTextZoom();
});
......@@ -80,6 +84,9 @@ Template.flashcards.onDestroyed(function () {
clearInterval(resizeInterval);
resizeInterval = undefined;
}
if (windowResizeSensor !== undefined) {
windowResizeSensor.off('resize');
}
});
Template.flashcards.helpers({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment