]> _ Git - fluidbook-html5.git/commitdiff
wip #7489 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 8 Aug 2025 16:26:37 +0000 (18:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 8 Aug 2025 16:26:37 +0000 (18:26 +0200)
_index.html
js/libs/fluidbook/fluidbook.elasticslide.js [new file with mode: 0644]
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.touch.js
style/elasticslide.less [new file with mode: 0644]
style/fluidbook.less

index 509fc7b08d511ea954692a1c07c2c4e957975024..e9fa4c86579611090639056a0d74b3609c17586e 100644 (file)
@@ -96,6 +96,7 @@
                         <div class="right"></div>
                     </div>
                 </div>
+                <div id="elasticpages"></div>
             </div>
         </div>
     </div>
diff --git a/js/libs/fluidbook/fluidbook.elasticslide.js b/js/libs/fluidbook/fluidbook.elasticslide.js
new file mode 100644 (file)
index 0000000..18b6c46
--- /dev/null
@@ -0,0 +1,66 @@
+function FluidbookElasticSlide(fluidbook) {
+    this.fluidbook = fluidbook;
+    this.init();
+}
+
+FluidbookElasticSlide.prototype = {
+    init: function () {
+        let $this = this;
+        if (this.isEnabled()) {
+            this.initPages();
+            $(this.fluidbook).on('fluidbook.orientationchange', function () {
+                $this.checkActive();
+            });
+            this.checkActive();
+            $(this.fluidbook).on('fluidbook.resize', function (e, data) {
+                $this.resize(data);
+            });
+        }
+    },
+
+    initPages: function () {
+        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);
+        }
+        $("#elasticpages").append(h);
+    },
+
+    checkActive: function () {
+        if (this.isActive()) {
+            this.switchToElastic();
+        } else {
+            this.switchToNormal();
+        }
+    },
+
+    switchToElastic: function () {
+        $('#elasticpages').show();
+        $("#pages").hide();
+    },
+
+    switchToNormal: function () {
+        $('#elasticpages').hide();
+        $("#pages").show();
+    },
+
+    isEnabled: function () {
+        return this.fluidbook.settings.slideTransitionsElastic == '1';
+    },
+    isActive: function () {
+        return true || (this.isEnabled() && this.fluidbook.displayOnePage);
+    },
+    preloadPage: function (page) {
+
+    },
+    resize: function (data) {
+
+        let w = parseFloat($("#fluidbook").css('width'));
+        let h = w / this.fluidbook.pageRatio;
+        $("#elasticpages .scrollholder").css('height', h * this.fluidbook.settings.pages);
+        $("#elasticpages .page").css({height: h});
+    },
+
+};
\ No newline at end of file
index 8e6429fc964c5f5c59eeb54409bc1b75056bf304..b1170333e9391027b6f9b3d0be8adb6fee589958 100644 (file)
@@ -38,6 +38,7 @@ Fluidbook.prototype = {
         }
 
         this.initSettings(settings);
+        this.pageRatio = this.settings.width / this.settings.height;
         this.secure = new FluidbookSecure(this);
 
         var $this = this;
@@ -87,6 +88,7 @@ Fluidbook.prototype = {
         this.cache = new FluidbookCache(this);
         this.service = new FluidbookService(this, this.settings.id);
         this.loader = new FluidbookLoader(this);
+
         if (!this.mobilefirst.enabled) {
             this.slider = new FluidbookSlider(this);
         }
@@ -169,6 +171,7 @@ Fluidbook.prototype = {
         this.interface = new FluidbookInterface(this);
         this.resize = new FluidbookResize(this);
         this.pagetransitions = new FluidbookPageTransition(this);
+        this.elasticslide = new FluidbookElasticSlide(this);
 
         this.stats = window.stats;
         this.stats.setup(this);
@@ -338,8 +341,14 @@ Fluidbook.prototype = {
             return;
         }
         $(doublePage).find('.' + position).remove();
-        var page = '<div class="page ' + position + '" id="page_' + 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>';
-        $(doublePage).append(page);
+        $(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>';
     },
 
     hidePage: function (position) {
index 5938a3cb0872cf7252c5e52a0f01aa6d5dc4c682..1b272d6f4d5379f7a9cc507b5aa9bc5d7b4ac3d3 100644 (file)
@@ -366,7 +366,4 @@ FluidbookTouch.prototype = {
         this.fluidbook.zoom.setOrigin(ox, oy, true);
     },
 
-    elasticSlide: function () {
-        return this.fluidbook.settings.slideTransitionsElastic == '1' && ['slide', 'portrait', 'slidefullwidth'].indexOf(this.fluidbook.pagetransitions.transitionType()) >= 0;
-    }
 };
\ No newline at end of file
diff --git a/style/elasticslide.less b/style/elasticslide.less
new file mode 100644 (file)
index 0000000..088cb09
--- /dev/null
@@ -0,0 +1,15 @@
+#elasticpages {
+  height: 100%;
+  width: 100%;
+  overflow: scroll;
+
+  .scrollholder {
+    position: relative;
+    width: 100%;
+
+    .page {
+      display: block;
+      position: relative;
+    }
+  }
+}
\ No newline at end of file
index b5e48567624f82db2c6c4f560a4d7c80fc19b0df..b7047d23463afaec099a628849edaa0c397bd64c 100644 (file)
@@ -2555,3 +2555,4 @@ body > input {
 @import "notes.less";
 @import "cart.less";
 @import "audioplayer.less";
+@import "elasticslide.less";
\ No newline at end of file