]> _ Git - fluidbook-html5.git/commitdiff
wip #2657 @9
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Apr 2019 12:05:07 +0000 (14:05 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Apr 2019 12:05:07 +0000 (14:05 +0200)
_index.html
images/interface.svg
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.mobilefirst.js
js/libs/fluidbook/fluidbook.pagetransitions.js
js/libs/fluidbook/fluidbook.resize.js
style/fluidbook.less
style/mixins.less
style/mobilefirst.less [new file with mode: 0644]
style/variables.less

index 4f281629f1dab005392c58ca867aa4126a5ddce1..915aa3f3ef0918958a66304a06a4824666401bd1 100644 (file)
             <div id="flip3dcontainer">
                 <canvas width="1024" height="1024"></canvas>
             </div>
-            <div id="fluidbook">
-                <div id="edges">
-                    <div class="edge left">
-                        <div class="top"></div>
-                        <div class="middle"></div>
-                        <div class="bottom"></div>
+            <div id="scroll">
+                <div id="fluidbook">
+                    <div id="edges">
+                        <div class="edge left">
+                            <div class="top"></div>
+                            <div class="middle"></div>
+                            <div class="bottom"></div>
+                        </div>
+                        <div class="edge right">
+                            <div class="top"></div>
+                            <div class="middle"></div>
+                            <div class="bottom"></div>
+                        </div>
                     </div>
-                    <div class="edge right">
-                        <div class="top"></div>
-                        <div class="middle"></div>
-                        <div class="bottom"></div>
+                    <div id="pagesnumbers" class="hidden">
+                        <div class="left"></div>
+                        <div class="right"></div>
+                    </div>
+                    <div id="pages" class="double">
+                        <div id="currentDoublePage" class="doublePage"></div>
+                        <div id="searchHighlights"></div>
+                        <div id="links"></div>
                     </div>
-                </div>
-                <div id="pagesnumbers" class="hidden">
-                    <div class="left"></div>
-                    <div class="right"></div>
-                </div>
-                <div id="pages" class="double">
-                    <div id="currentDoublePage" class="doublePage"></div>
-                    <div id="searchHighlights"></div>
-                    <div id="links"></div>
                 </div>
             </div>
         </div>
index a258cba8e0e3171b02db02578ef2ccad6ebae226..aa0b0aeb5b8d2aa8741163b05e2994c0392fde71 100644 (file)
         <path d="M36.5,55.1L21,39.6l15.5-15.5c0.3-0.3,0.3-0.7,0-0.9l-1.4-1.4c-0.3-0.3-0.7-0.3-0.9,0L17,39 c-0.2,0.2-0.2,0.4-0.2,0.6c0,0.2,0,0.4,0.2,0.5l17.2,17.2c0.3,0.3,0.7,0.3,0.9,0l1.4-1.4C36.8,55.7,36.8,55.3,36.5,55.1z M22,86.5 h2v-15h-2V86.5z M29.1,79l5.8-5.8c0.3-0.3,0.3-0.7,0-0.9l-0.5-0.5c-0.3-0.3-0.7-0.3-0.9,0L27.3,78c0,0,0,0-0.1,0l-0.5,0.5 c-0.1,0.1-0.2,0.3-0.2,0.5c0,0.2,0.1,0.4,0.2,0.5l0.5,0.5c0,0,0.1,0,0.1,0.1l6.2,6.2c0.3,0.3,0.7,0.3,0.9,0l0.5-0.5 c0.3-0.3,0.3-0.7,0-0.9L29.1,79z"/>
     </symbol>
     <symbol id="interface-minus" viewBox="0 0 50 50">
-        <rect x="16.5" y="23.5" class="st0" width="17" height="2.9"/>
+        <rect x="16.5" y="23.5" width="17" height="2.9"/>
+    </symbol>
+    <symbol id="interface-next-simple" viewBox="0 0 12 22">
+        <path d="M11.89,10.71L1.49,0.12c-0.15-0.15-0.4-0.15-0.55,0L0.13,0.95c-0.15,0.15-0.15,0.4,0,0.56l9.34,9.52
+               l-9.35,9.54c-0.15,0.15-0.15,0.4,0,0.56l0.82,0.84c0.15,0.15,0.4,0.15,0.55,0l10.39-10.6c0.08-0.09,0.11-0.2,0.1-0.31
+               C12,10.93,11.98,10.81,11.89,10.71z"/>
+    </symbol>
+    <symbol id="interface-previous-simple" viewBox="0 0 12 22">
+        <path d="M2.53,11.05l9.35-9.54c0.15-0.15,0.15-0.4,0-0.56l-0.82-0.84c-0.15-0.15-0.4-0.15-0.55,0L0.13,10.71
+               c-0.08,0.09-0.11,0.2-0.1,0.31C0,11.15,0.02,11.27,0.11,11.37l10.39,10.6c0.15,0.15,0.4,0.15,0.55,0l0.82-0.84
+               c0.15-0.15,0.15-0.4,0-0.56L2.53,11.05z"/>
     </symbol>
     <symbol id="interface-plus" viewBox="0 0 50 50">
-        <polygon class="st0"
-                 points="33.5,23.5 26.5,23.5 26.5,16.5 23.5,16.5 23.5,23.5 16.5,23.5 16.5,26.5 23.5,26.5 23.5,33.5 26.5,33.5 26.5,26.5 33.5,26.5 "/>
+        <polygon
+                points="33.5,23.5 26.5,23.5 26.5,16.5 23.5,16.5 23.5,23.5 16.5,23.5 16.5,26.5 23.5,26.5 23.5,33.5 26.5,33.5 26.5,26.5 33.5,26.5 "/>
     </symbol>
     <symbol id="bookmark-corner" viewBox="0 0 50 50">
         <path fill="currentColor" stroke="currentColor" d="M20.4,29.512c-0.213,0.21-0.488,0.356-0.799,0.407c-0.629,0.102-1.251-0.213-1.542-0.779l-3.212-6.252
index 3e265164043b44ad6c0fe37b510d1e73e4ed362d..502cd3ae3c839a5e25d66af8bfcbd01cf6f62d0a 100644 (file)
@@ -502,10 +502,10 @@ Fluidbook.prototype = {
         if (!this.displayOnePage) {
             var page = this.currentPage;
             var change = false;
-            if (side == 'left' && page % 2 == 1) {
+            if (side === 'left' && page % 2 === 1) {
                 page--;
                 change = true;
-            } else if (side == 'right' && page % 2 == 0) {
+            } else if (side === 'right' && page % 2 === 0) {
                 page++;
                 change = true;
             }
@@ -513,31 +513,37 @@ Fluidbook.prototype = {
                 window.location.hash = "/page/" + page;
             }
         }
-    }
-    ,
-    hideUnnecessaryButtons: function (page) {
-        var speed = 500;
-        if (page == undefined) {
-            page = this.currentPage;
-            speed = 0;
-        }
-
+    },
+    getButtonsVisibility: function (page) {
         var max = this.contentlock.getMaxPage();
-        if (this.contentlock.getMaxPage() % 2 === 1 && this.datas.mobileNavigationType !== 'portrait' && this.resize.orientation !== 'portrait') {
+        if (this.contentlock.getMaxPage() % 2 === 1 &&
+            this.datas.mobileNavigationType !== 'portrait' &&
+            this.datas.mobileNavigationType !== 'mobilefirst' &&
+            this.resize.orientation !== 'portrait') {
             max--;
         }
 
         var next = page < max;
         var previous = (page > 1);
+        return {previous: previous, next: next};
+    },
+    hideUnnecessaryButtons: function (page) {
+        var speed = 500;
+        if (page === undefined) {
+            page = this.currentPage;
+            speed = 0;
+        }
+
+        var visibility = this.getButtonsVisibility(page);
 
         if (Modernizr.csstransitions) {
-            if (next) {
+            if (visibility.next) {
                 $("#next").removeClass('hidden');
             } else {
                 $("#next").addClass('hidden');
             }
 
-            if (previous) {
+            if (visibility.previous) {
                 $("#previous").removeClass('hidden');
             } else {
                 $("#previous").addClass('hidden');
@@ -545,13 +551,13 @@ Fluidbook.prototype = {
         } else {
             $("#previous,#next").removeClass('hidden');
 
-            if (previous) {
+            if (visibility.previous) {
                 $("#previous:hidden").fadeIn(speed);
             } else {
                 $("#previous:visible").fadeOut(speed);
             }
 
-            if (next) {
+            if (visibility.next) {
                 $("#next:hidden").fadeIn(speed);
             } else {
                 $("#next:visible").fadeOut(speed);
index b564bb63f3778cc254a3d926d5cc122cfd89962e..cf42df4b5af9c064b7ae7fae2507e35f17b7ded3 100644 (file)
@@ -13,4 +13,38 @@ FluidbookMobileFirst.prototype = {
         $("html").addClass('mobilefirst');
         this.fluidbook.datas.soundTheme = '';
     },
+
+    beforeTransition: function (page) {
+        TweenLite.to("#scroll", this.fluidbook.pagetransitions.getTransitionDuration(page), {scrollTo: 0});
+    },
+
+    afterTransition: function (page) {
+        $('#pages .mf-nav').remove();
+        $("#pages").append(this.getFooterNavigation(page));
+        this.fluidbook.resize.resize();
+    },
+
+    resize: function () {
+        var h = $(".doublePage").outerHeight();
+        $('#pages .mf-nav').css('top', h);
+        h += $("#pages .mf-nav").outerHeight();
+
+        $("#pages,#fluidbook").css({height: h});
+        $("#pages").css('maxHeight', h);
+    },
+
+    getFooterNavigation: function (page) {
+        var visibility = this.fluidbook.getButtonsVisibility(page);
+        var footer = '<div class="mf-nav">';
+        if (visibility.previous) {
+            footer += '<a class="previous" href="#/page/' + (page - 1) + '">' + getSpriteIcon('interface-previous-simple') + __('Previous') + '</a>';
+        }
+        footer += '<span>' + page + '/' + this.fluidbook.datas.pages + '</span>';
+        if (visibility.next) {
+            footer += '<a class="next" href="#/page/' + (page + 1) + '">' + __('Next') + getSpriteIcon('interface-next-simple') + '</a>';
+        }
+        footer += '</div>';
+
+        return footer;
+    },
 }
\ No newline at end of file
index 997a733fa9a934cfee756c6e06e730348a3a6492..f21eba19e456751d1dec1c02d91dbb3374647e6a 100644 (file)
@@ -394,6 +394,11 @@ FluidbookPageTransition.prototype = {
         $(".axis_y").removeClass('axis_y');
         $(".axis_x").removeClass('axis_x');
         $("#links").hide();
+
+        if (this.fluidbook.mobilefirst.enabled) {
+            this.fluidbook.mobilefirst.beforeTransition(page);
+        }
+
         this.fluidbook.hideLoader();
         this.fluidbook.hideUnnecessaryButtons(page);
         var animationDuration = transition <= 1 ? 0 : parseFloat(this.fluidbook.datas.mobileTransitionDuration);
@@ -464,6 +469,9 @@ FluidbookPageTransition.prototype = {
             $this.transitionning = false;
         }, 10);
         this.fluidbook.links.initLinks();
+        if (this.fluidbook.mobilefirst.enabled) {
+            this.fluidbook.mobilefirst.afterTransition(page);
+        }
         $(this.fluidbook).trigger('fluidbook.page.change.end', [this.fluidbook.currentPage]);
     },
 
index 9ba7242204d009d5b91d48dd74512c2a07288bbc..cb6ed12e2a17040f0560a2623da753fb9c9b3798 100644 (file)
@@ -129,7 +129,7 @@ FluidbookResize.prototype = {
         var cssNavScale = [navScale, navScale];
         var cssHeaderScale = [headerScale, headerScale];
 
-        $("#main,#z").css({
+        $("#main,#z,#scroll").css({
             width: this.ww,
             height: this.hh
         });
@@ -166,26 +166,41 @@ FluidbookResize.prototype = {
         }
 
         this.bookScale = Math.min(aw / fww, ah / fhh);
+        var origin = ['50%', '50%'];
+        if (this.fluidbook.mobilefirst.enabled) {
+            this.bookScale = Math.min(aw / fww, 1);
+            origin[1] = '0%';
+        }
 
         var fw = this.bookScale * fww;
         var fh = this.bookScale * fhh;
         $("#fluidbook,#shadow").transform({
             scale: [this.bookScale, this.bookScale],
-            origin: ['50%', '50%']
+            origin: origin
         });
 
         // Hack to fix #2552
         if (this.fluidbook.support.iOS && this.fluidbook.pagetransitions.getTransitionType() === 'flip3d') {
             $('#fluidbook').css('transform', 'translate3d(0,0,-1px) scale(' + this.bookScale + ',' + this.bookScale + ')');
         }
+
         var top = marginTop + (ah - fhh) / 2;
+
         var left = marginLeft + (aw - fww) / 2;
+        if (this.fluidbook.mobilefirst.enabled) {
+            top = marginTop;
+        }
         $("#fluidbook,#shadow").css({
             top: top,
             left: left,
             width: fww,
             height: fhh
         });
+
+        if (this.fluidbook.mobilefirst.enabled) {
+            this.fluidbook.mobilefirst.resize();
+        }
+
         this.centerOffset = fw / 4;
         this.fluidbook.pagetransitions.centerBook();
 
@@ -244,7 +259,7 @@ FluidbookResize.prototype = {
         $('#loader').css({top: this.hh / 2, left: this.ww / 2});
         this.fluidbook.background.resize(this.ww, this.hh);
         if (this.fluidbook.slider) {
-            this.fluidbook.slider.resize(this.ww, this.hh, this.orientation == 'portrait');
+            this.fluidbook.slider.resize(this.ww, this.hh, this.orientation === 'portrait');
         }
 
         var timeout = 0;
index 89f35d0b6df64d1b598db98cf5f56eb9c8acd7f6..38c4be0da7b0efb839a565b67a2686b0047da5b4 100644 (file)
@@ -367,7 +367,8 @@ body, html {
   position: absolute;
   top: 0px;
   left: 0px;
-  overflow: hidden;
+  overflow-x: hidden;
+  overflow-y: hidden;
 }
 
 /* Search */
@@ -649,6 +650,16 @@ body, html {
   }
 }
 
+#scroll {
+  position: absolute;
+  top: 0;
+  left: 0;
+  z-index: 11;
+  overflow-x: hidden;
+  overflow-y: auto;
+  .hidescrollbar();
+}
+
 /* Fluidbook */
 #fluidbook {
   position: absolute;
@@ -2949,3 +2960,5 @@ body > input {
 #loadedcontents {
   display: none;
 }
+
+@import "mobilefirst.less";
\ No newline at end of file
index c0a2c9f7e99341c91b230f59923b5ad693a89d41..b2e9e7d35fde989fc97af37a9a6cff28d03d6296 100644 (file)
@@ -1,73 +1,81 @@
 .overlayBackground() {
-       background-color: @menu-overlay;
-       transition: opacity 400ms;
-       opacity: 0;
+  background-color: @menu-overlay;
+  transition: opacity 400ms;
+  opacity: 0;
 }
 
 .hideifnot(@display) when not (@display) {
-       display: none;
+  display: none;
 }
 
 .highlight-area(@color) {
-       border-color: @color;
-       background-color: fade(@color, 30%);
+  border-color: @color;
+  background-color: fade(@color, 30%);
 }
 
 .page-transition(@factor) {
-       -moz-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
-       -webkit-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
-       -ms-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
-       -o-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
-       transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
+  -moz-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
+  -webkit-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
+  -ms-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
+  -o-transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
+  transition: all unit(@page-transition-duration*@factor, s) ease-in-out;
 }
 
 .menu-color(@base-color) {
-       @green: max(45, min(255 - 45, green(@base-color)));
-       @red: max(45, min(255 - 45, red(@base-color)));
-       @blue: max(45, min(255 - 45, blue(@base-color)));
-       @secondary: overlay(rgb(@red, @green, @blue), #c0c0c0);
-       .menu-color-a(@base-color, @secondary);
+  @green: max(45, min(255 - 45, green(@base-color)));
+  @red: max(45, min(255 - 45, red(@base-color)));
+  @blue: max(45, min(255 - 45, blue(@base-color)));
+  @secondary: overlay(rgb(@red, @green, @blue), #c0c0c0);
+  .menu-color-a(@base-color, @secondary);
 }
 
 .menu-color(@base-color,@secondary) {
-       .menu-color-a(@base-color, @secondary);
+  .menu-color-a(@base-color, @secondary);
 }
 
 .menu-color-a(@background,@button) {
-       background: @background;
+  background: @background;
 
-       input[type="text"] {
-               background: @button;
-       }
+  input[type="text"] {
+    background: @button;
+  }
 
-       .fonctions {
-               a {
-                       background-color: @button;
-               }
-       }
+  .fonctions {
+    a {
+      background-color: @button;
+    }
+  }
 
-       .caption {
-               div.button, a {
-                       &.back {
-                               background-color: @button;
-                       }
-               }
-       }
+  .caption {
+    div.button, a {
+      &.back {
+        background-color: @button;
+      }
+    }
+  }
 
-       .chapters {
-               a:hover {
+  .chapters {
+    a:hover {
 
-                       background-color: @button;
-               }
-       }
+      background-color: @button;
+    }
+  }
 }
 
 .shadowedge-fade-item() {
-       transition-property: opacity;
-       &.hidden {
-               opacity: 0;
-       }
-       .ios & {
-               transition: none !important;
-       }
+  transition-property: opacity;
+  &.hidden {
+    opacity: 0;
+  }
+  .ios & {
+    transition: none !important;
+  }
 }
+
+.hidescrollbar() {
+  scrollbar-width: none;
+  -ms-overflow-style: none;
+  &::-webkit-scrollbar {
+    display: none;
+  }
+}
\ No newline at end of file
diff --git a/style/mobilefirst.less b/style/mobilefirst.less
new file mode 100644 (file)
index 0000000..8aac51f
--- /dev/null
@@ -0,0 +1,72 @@
+#shadow {
+  .mobilefirst & {
+    display: none;
+  }
+}
+
+.mf-nav {
+  position: absolute;
+  left: 0;
+  width: 100%;
+  height: unit(110*@css-scale, px);
+  padding: unit(30*@css-scale, px) 0;
+  color: @page-number-color;
+  font-size: unit(20*@css-scale, px);
+  font-weight: 600;
+  @media @small {
+    @s: 1.25;
+    font-size: unit(20*@s*@css-scale, px);
+    padding: unit(30*@s*@css-scale, px) 0;
+    height: unit(110*@s*@css-scale, px);
+  }
+
+  span {
+    display: block;
+    text-align: center;
+    margin-top: 0.9em;
+    @media @small {
+      margin-top: 0.7em;
+    }
+  }
+
+  a {
+    display: inline-block;
+    color: @arrows-color;
+    background-color: @arrows-background;
+    font-size: 1.1em;
+    line-height: 1;
+    font-weight: 400;
+    position: absolute;
+    top: 1.5em;
+    height: 2.5em;
+    width: 30%;
+    text-align: center;
+    padding-top: 0.7em;
+    @media @small {
+      width: 40%;
+    }
+
+    &.next {
+      right: 0;
+
+      svg {
+        right: .8em;
+      }
+    }
+
+    &.previous {
+      left: 0;
+
+      svg {
+        left: .8em;
+      }
+    }
+
+    svg {
+      position: absolute;
+      top: 0.8em;
+      height: 1em;
+      width: auto;
+    }
+  }
+}
\ No newline at end of file
index c3e2e461bbf7aa81eedb351e6f10851e2232fdac..6e39967174e18d818c5b69c8f9d6cb1cdf293c30 100644 (file)
@@ -1,2 +1,4 @@
 @import "book-variables";
-@font: 'Open Sans', Arial, Helvetica, sans-serif;
\ No newline at end of file
+
+@font: 'Open Sans', Arial, Helvetica, sans-serif;
+@small: ~"screen and (max-width: 640px)";
\ No newline at end of file