From: Vincent Vanwaelscappel Date: Thu, 1 Oct 2020 13:56:17 +0000 (+0200) Subject: wait #3739 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=21c3c2acd609cfd1a2ad8fb4931010750f093af2;p=fluidbook-html5.git wait #3739 @1 --- diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 12f00cc3..081a590a 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -413,6 +413,10 @@ Fluidbook.prototype = { return this.setCurrentPage('1'); } this.currentPageURL = page; + var anchor = false; + if (args.length > 3) { + anchor = args[3]; + } if (page !== $this.currentPage) { $($this).trigger('fluidbook.page.navigation', [page]); @@ -425,9 +429,15 @@ Fluidbook.prototype = { if (page !== $this.currentPage) { $this.pagetransitions.pageTransition(page); $this.stats.track(0, page); + if (anchor) { + $this.scrollToAnchorAfterTransition(anchor); + } + } else { + if (anchor) { + $this.scrollToAnchor(anchor); + } } $this.zoom.resetZoom(); - $this.splash.hide(); }, true); } else if (args[1] === 'landing') { @@ -467,6 +477,30 @@ Fluidbook.prototype = { return; }, + scrollToAnchor: function (anchor) { + if (!this.mobilefirst.enabled) { + return; + } + var id = $('[data-anchor="anchor"]').attr('id'); + TweenMax.to($("#scroll"), 0.5, {scrollTo: {y: '#' + id, offsetY: $('header').outerHeight() + 10}}); + }, + + scrollToAnchorAfterTransition: function (anchor) { + if (!this.mobilefirst.enabled) { + return; + } + var $this = this; + if (this.splash.isVisible()) { + $(this).one('fluidbook.splash.hide', function () { + $this.scrollToAnchor(anchor); + }); + } else { + $(this).one('fluidbook.page.change.end', function () { + $this.scrollToAnchor(anchor); + }); + } + }, + silentChangePage: function (page, transition) { if (page !== this.currentPage) { if (transition !== true) { diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 240ada7c..34cc2dbc 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -352,7 +352,7 @@ FluidbookLinks.prototype = { }, animateContentLink: function (link) { - var animations = link.data('animations'); + var animations = $(link).data('animations'); var $this = this; var defaults = ['ease', 'duration', 'delay']; @@ -583,7 +583,6 @@ FluidbookLinks.prototype = { } if (tweenmax) { TweenMax.fromTo(linkElement, duration, from, to); - console.log('TweenMax.fromTo', duration, from, to); } this.fluidbook.networkControl.pause((to.delay + duration + 0.5) * 1000); }, diff --git a/js/libs/fluidbook/fluidbook.splash.js b/js/libs/fluidbook/fluidbook.splash.js index d4dda1da..49f52b1b 100644 --- a/js/libs/fluidbook/fluidbook.splash.js +++ b/js/libs/fluidbook/fluidbook.splash.js @@ -57,6 +57,10 @@ FluidbookSplash.prototype = { } }, + isVisible: function () { + return $("#splash").is(':visible'); + }, + hideIfPossible: function () { if (!this.waitForReady && !this.waitForTimer) { this._hide();