]> _ Git - fluidbook-html5.git/commitdiff
wait #3739 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 1 Oct 2020 13:56:17 +0000 (15:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 1 Oct 2020 13:56:17 +0000 (15:56 +0200)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.splash.js

index 12f00cc37993d8437677979802834feac4eb7297..081a590abc107b732ab86906a579c959f18562a2 100644 (file)
@@ -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) {
index 240ada7c3a2d70af54cc7aff577848fb999f01b9..34cc2dbcc355c3f278a77192dac8cc0694a27ab6 100644 (file)
@@ -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);
     },
index d4dda1dad1e8c3455d76ec400b2d84507d9e7343..49f52b1b35221afdb38cb85db52dd5a528fed627 100644 (file)
@@ -57,6 +57,10 @@ FluidbookSplash.prototype = {
         }
     },
 
+    isVisible: function () {
+        return $("#splash").is(':visible');
+    },
+
     hideIfPossible: function () {
         if (!this.waitForReady && !this.waitForTimer) {
             this._hide();