From c2f4164fe8ad17115b05fd104967275c405c099d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 28 Aug 2023 16:39:55 +0200 Subject: [PATCH] wait #6220 @0.75 --- src/Links/ContentLink.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Links/ContentLink.php b/src/Links/ContentLink.php index de9b6a1..4539ec3 100644 --- a/src/Links/ContentLink.php +++ b/src/Links/ContentLink.php @@ -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)) { -- 2.39.5