]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6961
authorsoufiane <soufiane@cubedesigners.com>
Mon, 12 Aug 2024 09:24:42 +0000 (11:24 +0200)
committersoufiane <soufiane@cubedesigners.com>
Mon, 12 Aug 2024 09:24:42 +0000 (11:24 +0200)
resources/linkeditor/js/linkeditor.links.js
resources/linkeditor/style/inc/_links.sass

index ff1c6c9444d7bbb2ea61c174e22f0af2ba558af8..4ba9a74263d8cfab4e45454cc05c34200d55dac4 100644 (file)
@@ -1610,9 +1610,9 @@ LinkeditorLinks.prototype = {
 
             if ($('[data-id-preview="' + link.uid + '"]').length < 1) {
                 if(linkData.type === '35') {
-                    l.html("<div data-id-preview-wrap='" + link.uid + "'><div data-id-preview='" + link.uid + "'></div></div>")
+                    l.html("<div class='bg-preview'></div><div data-id-preview-wrap='" + link.uid + "'><div data-id-preview='" + link.uid + "'></div></div>")
                 } else {
-                    l.html("<div data-id-preview='" + link.uid + "'></div>")
+                    l.html("<div class='bg-preview'></div><div data-id-preview='" + link.uid + "'></div>")
                 }
             }
 
@@ -1633,7 +1633,7 @@ LinkeditorLinks.prototype = {
                 }
                 imgUrl = imgUrl + (imgUrl.includes('.svg') ? "#svgView(preserveAspectRatio(none))" : '')
                 let img = "<img src='" + imgUrl + "' />"
-                $("[data-id-preview=" + linkData.uid + "]").html(img)
+                $("[data-id-preview=" + linkData.uid + "]").css("position","absolute").html(img)
 
                 $("[data-id-preview=" + linkData.uid + "] img").css({
                     height: '100%',
@@ -1649,7 +1649,8 @@ LinkeditorLinks.prototype = {
                     'height': 'auto',
                     'width': 'max-content',
                     'font-family': hash,
-                    'color': linkData.extra
+                    'color': linkData.extra,
+                    'position': 'absolute'
                 })
                 this.updateFontSize(link)
             } else if (linkData.type === '39') {
@@ -1757,14 +1758,21 @@ LinkeditorLinks.prototype = {
         const links = all ? this.getLinksOfPage(this.linkeditor.currentPage) : [this.getLinksOfPage(this.linkeditor.currentPage)[this.getCurrentSelection().attr('fb-uid')]]
 
         for(let link in links) {
-            let animationText = $("[fb-uid=" + links[link].uid + "]").attr("fb-image_rollover")
+            let $link = $("[fb-uid=" + links[link].uid + "]")
+            let animationText = $link.attr("fb-image_rollover")
             let animations = this.resolveAnimation(animationText)
             let previewDiv = $("[data-id-preview=" + links[link].uid + "]")
             let el = previewDiv.get(0)
 
-            if(links[link].type === '15' || /\.(jpg|png|svg|webp|avif)$/.exec(links[link].image)) {
+            let animWithBackground = animations.filter((v) => v.backgroundColor)
+            let backgroundColor = animWithBackground.length > 0 ? animWithBackground[0].backgroundColor : null
+
+            console.log($link.find('.bg-preview'))
+
+            $link.find('.bg-preview').css('background-color',backgroundColor)
+            /*if(links[link].type === '15' || /\.(jpg|png|svg|webp|avif)$/.exec(links[link].image)) {
                 el = previewDiv.children().get(0)
-            }
+            }*/
 
             this.linkeditor.linksAnimations.executeAnimations(el, animations)
         }
@@ -1803,13 +1811,15 @@ LinkeditorLinks.prototype = {
 
         $("[data-id-preview-wrap="+link.uid+"]").css({
             transform: "scale("+zoom+")",
-            'transform-origin': "0 0"
+            'transform-origin': "0 0",
+            width: "calc(100% / "+zoom+")",
+            height: "calc(100% / "+zoom+")"
         })
     },
 
     clearPreview: function() {
-        $("[data-id-preview]").remove()
-        $("[data-action='links.animation']").removeClass("active")
+        $("[data-id-preview],.bg-preview").remove()
+        $("[data-id-preview]").parents('.link').css()
     },
 
     resolveAnimation: function(animationText) {
index 5a7b7610e16aa11784a226ae7c5689969e84f4db..c6a5c7e1fd7aa8da597b79ad77bcd6b87f106a73 100644 (file)
         .canvas .texts
             z-index: 2
 
+        .bg-preview
+            width: 100%
+            height: 100%
+            position: absolute
+
         [data-id-preview]:not(.link-text)
             overflow: hidden