function FluidbookElasticSlide(fluidbook) {
this.fluidbook = fluidbook;
+ this.skipChangePage = false;
+ this.scrollHolder = null;
+ this.ignoreScroll = false;
+ this.scrollingPage = null;
this.init();
}
}
},
+ resetPage: function (page) {
+ let p = $(this.fluidbook.createPage(page, 'epage_'));
+ p.find('.background').append('<img src="data/thumbnails/p' + page + '.jpg" alt=""/>');
+ if ($(p).find('.links').length === 0) {
+ p.append('<div class="links" />');
+ }
+ return p;
+ },
+
initPages: function () {
+ let $this = this;
let h = $('<div class="scrollholder"></div>');
for (let i = 1; i <= this.fluidbook.settings.pages; i++) {
- let p = $(this.fluidbook.createPage(i, 'epage_'));
- p.find('.background').append('<img src="data/thumbnails/p' + i + '.jpg" alt=""/>');
- h.append(p);
+ h.append(this.resetPage(i));
}
$("#elasticpages").append(h);
+ this.scrollHolder = $("#elasticpages .scrollholder");
+ this.scrollHolder.get(0).addEventListener('scroll', function (e) {
+ if (this.ignoreScroll) {
+ return;
+ }
+ let scrollPos = $this.scrollHolder.scrollTop();
+ let p = Math.round(100 * scrollPos / $this.pageHeight) / 100;
+ if (p % 1 !== 0) {
+ return;
+ }
+
+ let page = 1 + p;
+ if ($this.scrollingPage !== page) {
+ $this.scrollingPage = page;
+ if ($this.fluidbook.currentPage !== $this.scrollingPage) {
+ $this.skipChangePage = true;
+ $this.fluidbook.setCurrentPage($this.scrollingPage);
+ setTimeout(function () {
+ $this.skipChangePage = false;
+ }, 50)
+ $this.afterTransition();
+ }
+ }
+ });
},
checkActive: function () {
isEnabled: function () {
return this.fluidbook.settings.slideTransitionsElastic == '1';
},
+
isActive: function () {
return true || (this.isEnabled() && this.fluidbook.displayOnePage);
},
- preloadPage: function (page) {
+ setCurrentPage: function (page) {
+ if (this.skipChangePage) {
+ return;
+ }
+ let $this = this;
+ this.ignoreScroll = true;
+ gsap.to(this.scrollHolder, {
+ duration: 0.5, scrollTo: this.pageHeight * (page - 1), onComplete: function () {
+ $this.afterTransition();
+ $this.ignoreScroll = false;
+ }
+ });
+ },
+
+ afterTransition: function () {
+ this.fluidbook.links.initLinks();
},
- resize: function (data) {
+ resize: function (data) {
let w = parseFloat($("#fluidbook").css('width'));
- let h = w / this.fluidbook.pageRatio;
- $("#elasticpages .page,#elasticpages .scrollholder").css({height: h});
+ this.pageHeight = w / this.fluidbook.pageRatio;
+ $("#elasticpages .page,#elasticpages .scrollholder").css({height: this.pageHeight});
+
},
};
\ No newline at end of file
return;
}
$(doublePage).find('.' + position).remove();
- $(doublePage).append(this.createPage(pageNr, '#page_', position));
+ $(doublePage).append(this.createPage(pageNr, 'page_', position));
},
createPage: function (pageNr, idprexif, position) {
if (position === undefined) {
position = '';
}
- return '<div class="page ' + position + '" id="' + idprexif + pageNr + '" data-page="' + pageNr + '"><div class="background" page="' + pageNr + '"></div><div class="ctlinks" data-blendmode="normal"></div><div class="texts" highlight=""></div><div class="clinks" data-blendmode="normal"></div><div class="shade"></div></div>';
+
+ let id = idprexif + pageNr;
+ let c = $('#' + id);
+ if (c.length === 0) {
+ c = $('<div class="page ' + position + '" id="' + id + '" data-page="' + pageNr + '"></div>');
+ }
+
+ return $(c).html('<div class="background" page="' + pageNr + '"></div>' +
+ '<div class="ctlinks" data-blendmode="normal"></div>' +
+ '<div class="texts" highlight=""></div>' +
+ '<div class="clinks" data-blendmode="normal"></div>' +
+ '<div class="links"></div>'+
+ '<div class="shade"></div>');
},
hidePage: function (position) {
$this.splash.hide();
$this.menu.closeViewCallbackEvent(true);
}, true);
+
+ this.elasticslide.setCurrentPage(page);
+
} else if (args[1] === 'landing') {
$this.splash.hide();
if (this.landingpage !== undefined) {
}, timeout);
},
+ linksContainer: function (pageNr) {
+ let links;
+ if(this.fluidbook.elasticslide.isActive()){
+ links=$("#epage_"+pageNr +" .links");
+ }else {
+ links = $("#links").removeClass('right');
+ }
+ $(links).html('').show();
+ if (this.fluidbook.displayOnePage && pageNr % 2 === 1 && this.fluidbook.l10n.dir === 'ltr') {
+ $(links).addClass('right')
+ }
+ return links;
+ },
+
+
initLinks: function (pageNr) {
if (pageNr === undefined) {
leftPage = pageNr - 1;
}
- var links = $("#links").removeClass('right');
- $(links).html('').show();
- if (this.fluidbook.displayOnePage && pageNr % 2 === 1 && this.fluidbook.l10n.dir === 'ltr') {
- $(links).addClass('right')
- }
+ var links = this.linksContainer(pageNr);
var leftLinks, rightLinks;
leftLinks = rightLinks = true;
$this.loadbalancing = [];
$.each(data, function (i, server) {
$.ajax('https://' + server.h + '/status.txt', {
- dataType: 'text',
- timeout: 5000
+ dataType: 'text', timeout: 5000
}).done(function (data) {
if (data == '1') {
for (let i = 0; i < server.w; i++) {
_cb();
},
+ _pageContainer: function (page, child) {
+ if (child === undefined) {
+ child = '';
+ }
+ if (this.fluidbook.elasticslide.isActive()) {
+ return $("#epage_" + page + ' ' + child);
+ } else {
+ return $("page_" + page + ' ' + child);
+ }
+ },
+
_preloadPageAfterSecurityChecks: function (page, callback) {
if (page == undefined || page == 'undefined' || page > this.fluidbook.contentlock.getMaxPage() || page < 1) {
callback();
},
deletePage: function (page) {
+ if (this.fluidbook.elasticslide.isEnabled()) {
+ this.fluidbook.elasticslide.resetPage(page);
+ }
+
if (this.backgrounds[page] !== undefined) {
delete this.backgrounds[page];
}
setBackground: function (page, callback) {
var $this = this;
- var back = $("#page_" + page + ' .background');
+ var back = this._pageContainer(page, '.background');
this._loadBackground(page, function () {
+ $(back).html('');
$(back).addClass('r' + $this.fluidbook.support.resolution);
$(back).append($this.backgrounds[page]);
callback();
},
addTextContents: function (pageNr, callback) {
- var t = $("#page_" + pageNr + ' .texts');
+ var t = this._pageContainer(pageNr, '.texts');
if (this.fluidbook.support.svgtocanvas || this.fluidbook.support.pdftocanvas) {
} else {
$(t).append(this.texts[pageNr]);
callback();
},
+
loadPDFForTexts: function (callback) {
if (!this.fluidbook.support.pdftocanvas) {
callback();
overflow-y: scroll;
overflow-x: hidden;
scroll-snap-type: y mandatory;
- scroll-snap-stop: always;
-ms-overflow-style: none;
scrollbar-width: none;
+ .zoomed &{
+ overflow-y: hidden;
+ }
+
&::-webkit-scrollbar {
display: none;
}
display: block;
position: relative;
scroll-snap-align: center;
+ scroll-snap-stop: always;
}
}
}
\ No newline at end of file