]> _ Git - fluidbook-html5.git/commitdiff
wait #5118 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 22 Feb 2022 12:51:12 +0000 (13:51 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 22 Feb 2022 12:51:12 +0000 (13:51 +0100)
js/libs/fluidbook/fluidbook.links.js

index c73e2a8b0b0d32b15cffc5f7497975c8c42a56c5..e87727974f9a66b023769269b32abaf5796b7125 100644 (file)
@@ -588,9 +588,7 @@ FluidbookLinks.prototype = {
         to.repeat = parseInt(animation.repeat);
         var css = {};
 
-        if (animation.ease === undefined) {
-            animation.ease = "power1.out";
-        }
+        animation.ease = this.fixEase();
         if (animation.rotate !== undefined) {
             animation.rotation = animation.rotate;
         }
@@ -678,7 +676,7 @@ FluidbookLinks.prototype = {
             } else if ((animation.direction === 'down' && animation.type === 'unmask') || (animation.direction === 'up' && animation.type === 'reveal')) {
                 top = h;
             }
-            var rect = 'rect(' + top + 'px,' + right + 'px,' + bottom + 'px,' + left + 'px);';
+            var rect = 'rect(' + top + 'px,' + right + 'px,' + bottom + 'px,' + left + 'px)';
 
             if (animation.type === 'unmask') {
                 to.clip = rect;
@@ -757,9 +755,7 @@ FluidbookLinks.prototype = {
             animation.decimaldigitnumber = parseInt(animation.decimaldigitnumber);
             animation.letterspacing = parseFloat(animation.letterspacing);
 
-            var ea = to.ease.split('.');
-            var ease = window[ea[0]][ea[1]];
-
+            var ease = gsap.parseEase(to.ease);
             var options = {
                 duration: duration,
                 useEasing: true,
@@ -769,9 +765,9 @@ FluidbookLinks.prototype = {
                 decimal: animation.decimalseparator,
                 prefix: animation.prefix,
                 suffix: animation.suffix,
-                //easingFn: function (t, b, c, d) {
-                //    return b + ease.getRatio(Math.min(1, Math.max(0, t / d))) * c;
-                //}
+                easingFn: function (t, b, c, d) {
+                    return b + ease(Math.min(1, Math.max(0, t / d))) * c;
+                }
             };
 
             css = {
@@ -791,8 +787,7 @@ FluidbookLinks.prototype = {
         } else if (animation.type === 'draggable') {
             $(link).css('pointer-events', 'auto');
             var draggable = new Draggable(link, {
-                inertia: true,
-                type: 'x', onRelease: function () {
+                inertia: true, type: 'x', onRelease: function () {
                     var d = this;
                     if (animation.drop === 'clickhide') {
                         $('#links .link a').each(function () {
@@ -822,11 +817,24 @@ FluidbookLinks.prototype = {
         }
         if (usegsap) {
             to.duration = duration;
+            console.log(from,to);
             gsap.fromTo(linkElement, from, to);
         }
         this.fluidbook.networkControl.pause((to.delay + duration + 0.5) * 1000);
     },
 
+    fixEase: function (ease) {
+        if (ease === undefined) {
+            ease = "power1.out";
+        }
+        ease = ease.toLowerCase();
+        if (ease.indexOf('linear') === 0 || ease.indexOf('power0') === 0) {
+            ease = 'none';
+        }
+        ease = ease.replace('.ease', '.');
+        return ease;
+    },
+
     getLinkDataById: function (uid) {
         return this.fluidbook.settings.linksData[uid];
     },