]> _ Git - fluidbook_tools.git/commitdiff
wait #6220 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Aug 2023 14:39:55 +0000 (16:39 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Aug 2023 14:39:55 +0000 (16:39 +0200)
src/Links/ContentLink.php

index de9b6a16197d9aa8fadef43b684e053c989d617d..4539ec36c29d7046346f799b80430e3f890794d3 100644 (file)
@@ -2,17 +2,21 @@
 
 namespace Fluidbook\Tools\Links;
 
-class ContentLink extends Link {
+class ContentLink extends Link
+{
     public $defaultZIndex = 30;
     public $allowsAnimation = true;
     public $interactive = false;
     public $forceTexture = false;
+    public $parallax = 0;
 
-    public function getHTMLContainerClass() {
+    public function getHTMLContainerClass()
+    {
         return parent::getHTMLContainerClass() . ' contentLink';
     }
 
-    public function getAdditionnalContent() {
+    public function getAdditionnalContent()
+    {
         $res = parent::getAdditionnalContent();
         if ($this->allowsAnimation) {
             $animations = self::parseAnimations($this->image_rollover ?? 'none');
@@ -30,6 +34,10 @@ class ContentLink extends Link {
                 if (isset($animation['addzindex'])) {
                     $this->addzindex = $animation['addzindex'];
                 }
+                if (isset($animation['parallax'])) {
+                    $this->parallax = floatval($animation['parallax']);
+                    $animation['parallax'] = null;
+                }
             }
             if ($animations) {
                 $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" ';
@@ -40,14 +48,21 @@ class ContentLink extends Link {
                     $res .= ' data-animation-hide-on-leave ';
                 }
             }
+
+            if ($this->parallax != 0) {
+                $this->compiler->addJsLib('parallax', ['js/libs/fluidbook/fluidbook.parallax.js']);
+                $res .= ' data-parallax="' . $this->parallax . '" ';
+            }
         }
         if ($this->forceTexture && $this->getDepth() >= 40) {
             $res .= ' data-force-texture="1" ';
         }
+
         return $res;
     }
 
-    protected function _isFinallyHidden($animations) {
+    protected function _isFinallyHidden($animations)
+    {
         $hiddenAnimations = ['fadeout', 'unmask'];
         foreach ($animations as $animation) {
             if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) {
@@ -57,7 +72,8 @@ class ContentLink extends Link {
         return false;
     }
 
-    protected function _isHiddenFirst($animations) {
+    protected function _isHiddenFirst($animations)
+    {
         $hiddenAnimations = ['reveal', 'fadein', 'translatefrom'];
         foreach ($animations as $animation) {
             if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) {