]> _ Git - fluidbook-html5.git/commitdiff
wip #3785 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 21 Aug 2020 14:31:26 +0000 (16:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 21 Aug 2020 14:31:26 +0000 (16:31 +0200)
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.mobilefirst.js
style/fluidbook.less

index fc116a965b712dc3cc32c98b1ad228ae78a3d006..9718f0211d048901ad89ae9b9742c5bc37002940 100644 (file)
@@ -310,11 +310,11 @@ FluidbookLinks.prototype = {
         var $this = this;
 
         this.animateLinks();
+        $this.initAnimatedContentsLinks();
 
         setTimeout(function () {
             $this.fluidbook.initVideos();
             $this.initInlineSlideshows();
-            $this.initAnimatedContentsLinks();
             $this.fluidbook.l10n.translateAttributes();
         }, 200);
 
@@ -339,20 +339,36 @@ FluidbookLinks.prototype = {
         }
         var $this = this;
 
-        $(".contentLink[data-animation]").each(function () {
+        $(".contentLink[data-animations]").each(function () {
             $this.animateContentLink($(this));
         });
     },
 
     animateContentLink: function (link) {
+        var animations = link.data('animations');
+        var $this = this;
+
+        var defaults = ['ease', 'duration'];
+        var firstDefaults = {};
+        $.each(defaults, function (k, v) {
+            if (animations[0][v] !== undefined) {
+                firstDefaults[v] = animations[0][v];
+            }
+        });
+
+        $.each(animations, function (k, animation) {
+            $this.executeAnimation(link, $.extend({}, firstDefaults, animation));
+        });
+    },
+
+    executeAnimation: function (link, animation) {
         link = $(link);
         var linkElement = $(link).get(0);
-        var animation = link.data('animation');
         if (animation.type === undefined || animation.type === '') {
             animation.type = 'none';
         }
         var defaultParams = {};
-        var globalDefault = {zindex: 0};
+        var globalDefault = {zindex: 0, x: 0, y: 0};
         var w = parseFloat(link.css('width'));
         var cx = w / 2;
         var h = parseFloat(link.css('height'));
@@ -377,13 +393,36 @@ FluidbookLinks.prototype = {
         if (animation.delay !== undefined) {
             to.delay = parseFloat(animation.delay);
         }
-        if (animation.type === 'fadein') {
+        if (animation.type === 'translatefrom') {
+            from.display = 'none';
+            to.display = 'block';
+
+            from.x = animation.x;
+            from.y = animation.y;
+
+            to.x = 0;
+            to.y = 0;
+        } else if (animation.type === 'translate') {
+            from.display = 'none';
+            to.display = 'block';
+            from.x = 0;
+            from.y = 0;
+            to.x = animation.x;
+            to.y = animation.y;
+        } else if (animation.type === 'fadein') {
+            from.display = 'none';
+            to.display = 'block';
             from.opacity = 0;
             to.opacity = 1;
         } else if (animation.type === 'fadeout') {
             from.opacity = 1;
             to.opacity = 0;
         } else if (animation.type === "unmask" || animation.type === 'reveal') {
+            if (animation.type === 'reveal') {
+                from.display = 'none';
+                to.display = 'block';
+            }
+
             var top = 0;
             var right = w;
             var bottom = h;
@@ -525,7 +564,12 @@ FluidbookLinks.prototype = {
         css = $.extend({zIndex: 500 + parseInt(animation.zindex)}, css);
 
         link.css(css);
-        link.show();
+        if (from.display !== undefined && from.display !== 'none') {
+            link.show();
+        }
+        if (from.display !== undefined && from.display === 'none') {
+            link.hide();
+        }
         if (tweenmax) {
             TweenMax.fromTo(linkElement, duration, from, to);
         }
index 634781b1f3c56ea4edd3c4f4b9e69208c5bd2958..8220a85923b0ab09f8a3be20f63f8b2ac2f56bda 100644 (file)
@@ -69,7 +69,7 @@ FluidbookMobileFirst.prototype = {
         }
         var $this = this;
         var delay = 800;
-        $("#links .link:not(.revealed):visible, .clinks [data-animation]:not(.revealed)").each(function () {
+        $("#links .link:not(.revealed):visible, .clinks [data-animations]:not(.revealed)").each(function () {
             var rect = $(this).get(0).getBoundingClientRect();
             if (rect.top < $this.fluidbook.resize.hh) {
                 $(this).addClass('revealed');
@@ -82,7 +82,7 @@ FluidbookMobileFirst.prototype = {
                     setTimeout(function () {
                         $(iframe).attr('src', url);
                     }, 10);
-                } else if ($(this).is('[data-animation]')) {
+                } else if ($(this).is('[data-animations]')) {
                     var $link = this;
                     setTimeout(function () {
                         $this.fluidbook.links.animateContentLink($link);
index db65bdefd034b5c20ab7859efb6c64576b65ab3a..599fd7afbd35b7f4893270bcf2fe3af66665a5dc 100644 (file)
@@ -1272,14 +1272,10 @@ html.ios body.portrait #interface {
   position: absolute;
   pointer-events: none;
 
-  &[data-animation-type="reveal"], &[data-animation-type="fadein"] {
-    display: none;
-  }
-
   &.textLink {
     white-space: nowrap;
 
-    &[data-animation-type] {
+    &[data-animations] {
       transform-origin: 0 100%;
       opacity: 0;
     }