]> _ Git - fluidbook-html5.git/commitdiff
wip #7489 @21
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 25 Aug 2025 17:14:10 +0000 (19:14 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 25 Aug 2025 17:14:10 +0000 (19:14 +0200)
_index.html
js/libs/fluidbook/fluidbook.elasticslide.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.resize.js
js/libs/fluidbook/fluidbook.touch.js
style/elasticslide.less
style/interface.less
style/links.less
style/slider.less

index e9fa4c86579611090639056a0d74b3609c17586e..46240f490de771dd6840e165a6b62ca698ba23e0 100644 (file)
@@ -90,7 +90,7 @@
                 <div id="pages" class="double">
                     <div id="currentDoublePage" class="doublePage" aria-hidden="true"></div>
                     <div id="searchHighlights" aria-hidden="true"></div>
-                    <div id="links"></div>
+                    <div id="links" class="links"></div>
                     <div id="shade" aria-hidden="true">
                         <div class="left"></div>
                         <div class="right"></div>
index db4525391a44f0a0b5de227ebd3c92fc9130c379..2cea1d0ca74f39d3c54250124801d855c579835e 100644 (file)
@@ -40,28 +40,33 @@ FluidbookElasticSlide.prototype = {
         $("#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;
-            }
+            $this.scrolling();
+        });
+    },
+
+    scrolling: function () {
+        let $this = this;
+        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();
-                }
+        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($this.scrollingPage);
             }
-        });
+        }
     },
 
     checkActive: function () {
@@ -73,13 +78,11 @@ FluidbookElasticSlide.prototype = {
     },
 
     switchToElastic: function () {
-        $('#elasticpages').show();
-        $("#pages").hide();
+        $("body").addClass('elastic');
     },
 
     switchToNormal: function () {
-        $('#elasticpages').hide();
-        $("#pages").show();
+        $("body").removeClass('elastic');
     },
 
     isEnabled: function () {
@@ -87,7 +90,7 @@ FluidbookElasticSlide.prototype = {
     },
 
     isActive: function () {
-        return true || (this.isEnabled() && this.fluidbook.displayOnePage);
+        return (this.isEnabled() && this.fluidbook.displayOnePage);
     },
 
     setCurrentPage: function (page) {
@@ -98,14 +101,28 @@ FluidbookElasticSlide.prototype = {
         this.ignoreScroll = true;
         gsap.to(this.scrollHolder, {
             duration: 0.5, scrollTo: this.pageHeight * (page - 1), onComplete: function () {
-                $this.afterTransition();
+                $this.afterTransition(page);
                 $this.ignoreScroll = false;
             }
         });
     },
 
-    afterTransition: function () {
-        this.fluidbook.links.initLinks();
+    afterTransition: function (page) {
+        if (page === undefined) {
+            page = this.fluidbook.currentPage;
+        } else {
+            this.fluidbook.currentPage = page;
+        }
+        let $this = this;
+        $("#elasticpages .scrollholder .page.current:not(#epage_" + page + ")").removeClass('current');
+        $("#epage_" + page).addClass('current');
+        this.fluidbook.loader.loadPage(page, false, false, function () {
+            $this.fluidbook.loader.loadPage(page + 1, false, false, function () {
+                $this.fluidbook.loader.loadPage(page - 1, false, false, function () {
+                });
+            })
+        });
+        this.fluidbook.links.initLinks(page);
     },
 
     resize: function (data) {
index 909678a09b7b3dcbf2af86c46ad06097cf868de2..b711dc6f4bc5ef7091ad4cf32944c85d13b23c2e 100644 (file)
@@ -355,12 +355,7 @@ Fluidbook.prototype = {
             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>');
+        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) {
@@ -546,6 +541,7 @@ Fluidbook.prototype = {
                 $($this).trigger('fluidbook.page.navigation', [page]);
                 $($this).trigger('changePage', [page]);
             }
+
             if (this.landingpage !== undefined) {
                 this.landingpage.hide();
             }
@@ -841,11 +837,17 @@ Fluidbook.prototype = {
         var rand = Math.round(Math.random() * 100000);
         this.waiters.push(rand);
         return rand;
-    }, waiterActive: function (id) {
+    },
+
+    waiterActive: function (id) {
         return this.waiters.indexOf(id) > -1;
-    }, resetWaiters: function () {
+    },
+
+    resetWaiters: function () {
         this.waiters = [];
-    }, physicalToVirtual: function (page) {
+    },
+
+    physicalToVirtual: function (page) {
         return this.settings.numerotation[page - 1];
     },
 
index 518fdddf70e4261df37b687c5dc6914db7b2edd6..8e3482c396b9bbedcc4f91c07a83f0d0167b8c87 100644 (file)
@@ -163,13 +163,13 @@ FluidbookLinks.prototype = {
             return true;
         });
 
-        $(document).on('mouseenter', '#links a.image_rollover', function () {
+        $(document).on('mouseenter', '.links a.image_rollover', function () {
             var id = $(this).closest('[data-id]').data('id');
             var iid = 'i_' + id;
             $this.rolloverEnter(iid);
         });
 
-        $(document).on('mouseleave', '#links a.image_rollover', function () {
+        $(document).on('mouseleave', '.links a.image_rollover', function () {
             var id = $(this).closest('[data-id]').data('id');
             var iid = 'i_' + id;
             $this.rolloverLeave(iid);
@@ -650,9 +650,9 @@ FluidbookLinks.prototype = {
 
     linksContainer: function (pageNr) {
         let links;
-        if(this.fluidbook.elasticslide.isActive()){
-            links=$("#epage_"+pageNr +" .links");
-        }else {
+        if (this.fluidbook.elasticslide.isActive()) {
+            links = $("#epage_" + pageNr + " .links");
+        } else {
             links = $("#links").removeClass('right');
         }
         $(links).html('').show();
@@ -693,11 +693,15 @@ FluidbookLinks.prototype = {
 
         $("#background .links .bookmark").remove();
 
-        if (leftLinks) {
-            this.setLinksInContainer(leftPage, 'left');
-        }
-        if (rightLinks) {
-            this.setLinksInContainer(rightPage, 'right');
+        if (this.fluidbook.elasticslide.isActive()) {
+            this.setLinksInContainer(pageNr, false);
+        } else {
+            if (leftLinks) {
+                this.setLinksInContainer(leftPage, 'left');
+            }
+            if (rightLinks) {
+                this.setLinksInContainer(rightPage, 'right');
+            }
         }
 
         if (links.find('.link.multimedia iframe').length > 0) {
@@ -722,7 +726,7 @@ FluidbookLinks.prototype = {
             }, $(this).data('delay') * 1000);
         });
 
-        this.animateLinks();
+        this.animateLinks(this.fluidbook.elasticslide.isActive() ? $('#elasticpages .page.current .links') : $(document));
         $this.initAnimatedContentsLinks();
 
         setTimeout(function () {
@@ -766,8 +770,15 @@ FluidbookLinks.prototype = {
     },
 
     setLinksInContainer: function (page, side) {
-        var links = $("#links");
-        links.append('<div class="' + side + 'Container container"><div class="linksHolder"></div></div>');
+        let links;
+        if (this.fluidbook.elasticslide.isActive()) {
+            links = this.fluidbook.loader._pageContainer(page, '.links');
+        } else {
+            links = $("#links");
+        }
+        side = (side ? side : 'elasticSlide');
+
+        links.html('<div class="' + side + 'Container container"><div class="linksHolder"></div></div>');
         var container = links.find('.' + side + 'Container');
         var llinks = this.fluidbook.loader.handleExtension(this.fluidbook.settings.links[page]);
         if (llinks !== '') {
@@ -786,13 +797,13 @@ FluidbookLinks.prototype = {
         }
     },
 
-    animateLinks: function () {
+    animateLinks: function (container) {
         if (this.fluidbook.settings.linkBlinkTime == 0 || this.fluidbook.settings.linkBlinkRepetition == 0 || !this.fluidbook.settings.mobileLinksRevealAnim || this.fluidbook.menu.viewMode()) {
             return;
         }
         var $this = this;
         setTimeout(function () {
-            $this.doAnimateLinks();
+            $this.doAnimateLinks(container);
         }, 650);
     },
 
@@ -802,10 +813,11 @@ FluidbookLinks.prototype = {
         }
         var $this = this;
         if (container === undefined) {
-            container = $("#currentDoublePage,#links");
+            container = $("#currentDoublePage,.page.current");
         }
-
-        $(container).find('[data-animations]').each(function () {
+        let linksToAnimate = $(container).find('[data-animations]');
+        console.log(linksToAnimate);
+        linksToAnimate.each(function () {
             $this.animateContentLink($(this), true);
         });
     },
@@ -851,20 +863,20 @@ FluidbookLinks.prototype = {
             return;
         }
 
+        console.log(container);
+
         var animateBookmarks = (this.fluidbook.settings.bookmarkBlinkOnPageChange == true);
 
         var $this = this;
         var links = $(container).find(".link a[data-animation]");
-
         if (!this.fluidbook.mobilefirst.enabled) {
             $(links).each(function () {
                 $this.animateLink(this, additionalDelay);
             });
         }
 
-
         if (animateBookmarks) {
-            this._blink($("#links .bookmark:not([data-enabled])"));
+            this._blink($(".links").find("bookmark:not([data-enabled])"));
         }
         this.updateAttachedLinks();
     },
@@ -986,7 +998,7 @@ FluidbookLinks.prototype = {
         var $this = this;
 
         if (this.fluidbook.slideshow !== undefined) {
-            $("#links .fb-slideshow, #currentDoublePage .fb-slideshow").each(function () {
+            $("#links .fb-slideshow, .page .fb-slideshow, #currentDoublePage .fb-slideshow").each(function () {
                 if (!$this.isDelayed(this)) {
                     $this.fluidbook.slideshow.initInlineSlideshow(this);
                 }
@@ -995,9 +1007,10 @@ FluidbookLinks.prototype = {
         }
     },
 
+
     resize: function () {
         var $this = this;
-        $("#links .link.iframe").each(function () {
+        $('.links .link.iframe').each(function () {
             var iframe = $(this).find("iframe");
             var scale = $(iframe).data('scale');
             var w = $(this).outerWidth();
index 00fcdcab17c12e27a378015bfdec823d02553fa4..8b1db3c59de99d907943987090e656200ae81c0b 100644 (file)
@@ -374,61 +374,74 @@ FluidbookLoader.prototype = {
         }
     },
 
-    loadPage: function (pageNr, doublePage, position, callback) {
-
-        if (pageNr <= 0 || pageNr > this.fluidbook.settings.pages) {
-            callback();
-            return;
+    loadPage: function (pageNr, container, position, callback) {
+        if (!$(container).length == 0) {
+            container = false;
         }
-
-        // The page is already here.
-        if ($(doublePage).find('.' + position + '#page_' + pageNr).length > 0) {
+        if (position !== 'left' && position !== 'right') {
+            position = false;
+        }
+        pageNr = parseInt(pageNr);
+        if (pageNr <= 0 || pageNr > this.fluidbook.settings.pages) {
             callback();
             return;
         }
 
-        // Si une page de gauche existe déjà dans la double page, on la retire
-        $(doublePage).find('.' + position).each(function () {
-            if ($(this).attr('id') != 'page_' + pageNr || pageNr == 0) {
-                $(this).remove();
+        if (container) {
+            // The page is already here.
+            if ($(container).find('.' + position + '#page_' + pageNr).length > 0) {
+                callback();
+                return;
             }
-        })
 
-        var page;
+            // Si une page de gauche existe déjà dans la double page, on la retire
+            $(container).find('.' + position).each(function () {
+                if ($(this).attr('id') != 'page_' + pageNr || pageNr == 0) {
+                    $(this).remove();
+                }
+            })
+        }
+        var page = this._pageContainer(pageNr);
         // Si la page existe déjà, on la place à la bonne position et on l'affiche
-        if ($("#page_" + pageNr).length > 0) {
-            page = $("#page_" + pageNr);
-            if ($(doublePage).find("#page_" + pageNr).length === 0) {
-                $(doublePage).append(page);
-            }
-            if (!$(page).hasClass(position)) {
-                if (position === 'left') {
-                    $(page).removeClass('right');
-                } else {
-                    $(page).removeClass('left');
+        if (container) {
+            if ($(page).length > 0) {
+
+                if ($(container).find("#page_" + pageNr).length === 0) {
+                    $(container).append(page);
                 }
-                $(page).addClass(position);
-            }
-            if (!$(page).is(':visible')) {
-                $(page).show();
+                if (!$(page).hasClass(position)) {
+                    if (position === 'left') {
+                        $(page).removeClass('right');
+                    } else {
+                        $(page).removeClass('left');
+                    }
+                    $(page).addClass(position);
+                }
+
+                if (!$(page).is(':visible')) {
+                    $(page).show();
+                }
+
+                this.addCLinks(pageNr);
+                callback();
+                return;
             }
 
-            this.addCLinks(pageNr);
-            callback();
-            return;
+
+            this.fluidbook.initPage(pageNr, container, position);
+            $(container).append(page);
+            $(page).addClass(position);
         }
 
-        this.fluidbook.initPage(pageNr, doublePage, position);
-        var version = this.getVersionToLoad(parseInt(pageNr));
-        page = $("#page_" + pageNr);
-        $(doublePage).append(page);
+
         this.renderPDFTextsCanvas();
         this.renderTextsCanvas();
         $(page).show();
-        $(page).addClass(position);
         var $this = this;
         this.loadDatas(pageNr, function () {
-            $(page).addClass(position);
+            if (container) {
+                $(page).addClass(position);
+            }
             $this.addCLinks(pageNr);
             $this.fluidbook.resize.resizeLinks();
             callback();
@@ -437,7 +450,7 @@ FluidbookLoader.prototype = {
 
     addCLinks: function (pageNr) {
         var $this = this;
-        var page = $("#page_" + pageNr);
+        var page = this._pageContainer(pageNr);
         $.each(['clinks', 'ctlinks'], function (k, cont) {
             var normal = $(page).children('.' + cont + '[data-blendmode="normal"]');
             $.each($this.fluidbook.settings[cont][pageNr], function (blendmode, links) {
@@ -507,9 +520,8 @@ FluidbookLoader.prototype = {
         var $this = this;
         var back = this._pageContainer(page, '.background');
         this._loadBackground(page, function () {
-            $(back).html('');
             $(back).addClass('r' + $this.fluidbook.support.resolution);
-            $(back).append($this.backgrounds[page]);
+            $(back).html($this.backgrounds[page]);
             callback();
         });
     },
index 6ed1a9a89b68471b0ba2500c2144dd2ce305b598..0974d4e8efcc3df07ee5d4dad40b70618ccf3087 100644 (file)
@@ -378,7 +378,7 @@ FluidbookResize.prototype = {
     },
 
     resizeLinks: function () {
-        $('#links .container,.clinks,.ctlinks,#searchHighlights').css({
+        $('#links .container, .page .links,.clinks,.ctlinks,#searchHighlights').css({
             transform: 'scale(' + this.bookScale + ')',
         });
     },
index 1b272d6f4d5379f7a9cc507b5aa9bc5d7b4ac3d3..5d9cdf5cd2369e549c6063477f74efd5fff25a47 100644 (file)
@@ -221,7 +221,7 @@ FluidbookTouch.prototype = {
         if ($(".mview:visible").length > 0) {
             return false;
         }
-        if (this.fluidbook.zoom.zoom === 1) {
+        if (!this.fluidbook.elasticslide.isActive() && this.fluidbook.zoom.zoom === 1) {
             if (this.startX === -1 || this.startY === -1 || type === 'start') {
                 this.startX = e.center.x;
                 this.startY = e.center.y;
index d9c2fead2e6bf8fe6f8affbb17207477317edd89..ce35170a7e5e0069bbca920a8eb5bccd3c4526fa 100644 (file)
@@ -1,6 +1,15 @@
+.elastic #pages {
+  display: none;
+}
+
 #elasticpages {
   height: 100%;
   width: 100%;
+  display: none;
+
+  .elastic & {
+    display: block;
+  }
 
 
   .scrollholder {
@@ -13,7 +22,7 @@
     -ms-overflow-style: none;
     scrollbar-width: none;
 
-    .zoomed &{
+    .zoomed & {
       overflow-y: hidden;
     }
 
index 74d5881302407180336fb92f966332e7c76ddd05..7823f89a018bd6372a3501499883b55858c173aa 100644 (file)
   color: @arrows-color;
   background-color: @arrows-background;
 
+  .elastic & {
+    display: none !important;
+  }
+
   a {
     position: absolute;
     left: 0;
     width: 100%;
 
-    &:hover{
+    &:hover {
       svg {
         transform: translateX(5px);
       }
     }
 
-    &:focus{
-      .keyboard-navigating &{
+    &:focus {
+      .keyboard-navigating & {
         svg {
           transform: translateX(5px);
         }
@@ -75,7 +79,7 @@
       }
     }
 
-    &:focus{
+    &:focus {
       .keyboard-navigating & {
         svg {
           transform: translateX(-5px);
 }
 
 
-
 .interfacecomponent {
   transition: opacity 100ms, top 100ms;
   opacity: 1;
     color: inherit;
     font-size: 1em;
     cursor: pointer;
-    border:0;
+    border: 0;
     background-color: transparent;
   }
 
index 3a8976c590d8172aa504dba8699269cc931bbfe4..0c6ca1501224dfcef6b0a38b83a01160f4a13561 100644 (file)
@@ -1,11 +1,30 @@
 /* Links */
 
-#links {
+#links, .page .links {
   position: absolute;
-  top: 0px;
-  left: 0px;
+  top: 0;
+  left: 0;
   z-index: 4;
   background-color: rgba(0, 0, 0, 0.001);
+
+  .link {
+    position: absolute;
+    cursor: auto;
+  }
+
+  .nonlinkarea {
+    width: 100%;
+    height: 100%;
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    display: block;
+
+    .zoom-disabled & {
+      cursor: auto !important;
+      pointer-events: none;
+    }
+  }
 }
 
 #links .leftContainer {
@@ -16,7 +35,7 @@
   z-index: 0;
 }
 
-#links, #links .container, .clinks, .ctlinks, #searchHighlights {
+#links, #links .container, .page.links, .page .links .container, .clinks, .ctlinks, #searchHighlights {
   transform-origin: 0 0 0;
 }
 
   }
 }
 
-#links .link {
-  position: absolute;
-  cursor: auto;
-}
-
 .linkshowclose {
   position: absolute;
   display: block;
   }
 }
 
-#links .nonlinkarea {
-  width: 100%;
-  height: 100%;
-  position: absolute;
-  top: 0px;
-  left: 0px;
-  display: block;
-
-  .zoom-disabled & {
-    cursor: auto !important;
-    pointer-events: none;
-  }
-}
 
 html.mobile [data-visibility-os="desktop"], html.desktop [data-visibility-os="mobile"] {
   display: none !important;
index f635a0adae099eb6ab866d6e8be6f72dd9948dcf..d7126d323e18ec2b170d2423e18ee02e37fe8296 100644 (file)
     touch-action: none;
   }
 
+  .elastic & {
+    display: none;
+  }
+
+
   position: absolute;
   height: 6px;
   bottom: 20px;