]> _ Git - fluidbook_tools.git/commitdiff
wait #6200
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Feb 2024 19:53:43 +0000 (20:53 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Feb 2024 19:53:43 +0000 (20:53 +0100)
src/Links/ContentLink.php
src/Links/ImageLink.php

index 871bc6fa04ab4739967fe9ebf381d5755cc3abfe..35390ccc6051c6e6ea3a91496df2b0592791e53f 100644 (file)
@@ -10,6 +10,8 @@ class ContentLink extends Link
     public $forceTexture = false;
     public $parallax = 0;
 
+    protected $contentInlineStyles='';
+
     public function getHTMLContainerClass()
     {
         $res = parent::getHTMLContainerClass() . ' contentLink';
@@ -52,11 +54,14 @@ class ContentLink extends Link
                     $res .= ' data-animation-hide-on-leave ';
                 }
                 if ($s = $this->_isZoomedIn($animations)) {
-                    $res .= ' data-animation-zoomed-in="' . $s . '" ';
+                    $res .= ' data-animation-zoomed-in="' . $s['scale'] . '" ';
                 }
 
                 if ($s = $this->_isZoomedOut($animations)) {
-                    $res .= ' data-animation-zoomed-out="' . $s . '" ';
+                    $scale = $s['scale'] ?? 1;
+                    $to = $s['transformOrigin'] ?? '50% 50%';
+                    $res .= ' data-animation-zoomed-out="' . $scale . '" data-animation-zoomed-origin="' . $to . '" ';
+                    $this->contentInlineStyles .= 'transform:scale(' . $scale . ');transform-origin:' . $to . ';';
                 }
             }
 
@@ -80,12 +85,12 @@ class ContentLink extends Link
 
     protected function _isZoomedIn($animations)
     {
-        return $this->_hasAnimation($animations, ['zoomin', 'scaleto'], 'scale');
+        return $this->_hasAnimation($animations, ['zoomin', 'scaleto'], ['scale', 'transformOrigin']);
     }
 
     protected function _isZoomedOut($animations)
     {
-        return $this->_hasAnimation($animations, ['zoomout', 'scalefrom'], 'scale');
+        return $this->_hasAnimation($animations, ['zoomout', 'scalefrom'], ['scale', 'transformOrigin']);
     }
 
     protected function _isFinallyHidden($animations)
@@ -100,7 +105,14 @@ class ContentLink extends Link
                 if ($return === null) {
                     return true;
                 }
-                return $animation[$return];
+                $res = [];
+                foreach ($return as $item) {
+                    if (isset($animation[$item])) {
+                        $res[$item] = $animation[$item];
+                    }
+                }
+                return $res;
+
             }
         }
         return false;
index a75e72dcd298eed2573a5fd7902e5210533003d0..977f912c6c443a19c0b3b224cae570c4b6f432a0 100644 (file)
@@ -2,19 +2,23 @@
 
 namespace Fluidbook\Tools\Links;
 
-class ImageLink extends ContentLink {
+class ImageLink extends ContentLink
+{
 
-    public function getImageUrl() {
+    public function getImageUrl()
+    {
         return Link::getUniversalLocation($this->to, false);
     }
 
-    public function getCSS() {
+    public function getCSS()
+    {
         $res = parent::getCSS();
         $this->copyExternalFile($this->to);
         return $res;
     }
 
-    public function getAdditionnalContent() {
+    public function getAdditionnalContent()
+    {
         $res = parent::getAdditionnalContent();
         $res .= ' data-image="' . $this->getImageUrl() . '"';
         if (isset($this->image_rollover)) {
@@ -23,12 +27,13 @@ class ImageLink extends ContentLink {
         return $res;
     }
 
-    public function getHTMLContent() {
+    public function getHTMLContent()
+    {
         // For zoomin & zoomout animations
         if (isset($this->image_rollover) && stristr($this->image_rollover, 'type=zoom')) {
-            return '<div class="img" style="background-image:url(' . $this->getImageUrl() . ');"></div>';
+            return '<div class="img" style="background-image:url(' . $this->getImageUrl() . ');' . $this->contentInlineStyles . '"></div>';
         } else {
-            return '<img src="' . $this->getImageUrl() . '" />';
+            return '<img src="' . $this->getImageUrl() . '" style="' . $this->contentInlineStyles . '" />';
         }
     }