YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator Class Reference

Add a pre-defined effect to any of your content elements. More...

Public Member Functions

 __construct ($db)
 Load all widget settings from database and fill object. More...
 
 init ()
 Initialize: prepare proerties and load javascript. More...
 
 printObject ()
 Print all object data. More...
 

Public Attributes

 $contentAnimatorClass = 'slideUp'
 
 $contentAnimatorScrollValue = '620'
 
 $widget = ''
 

Detailed Description

Add a pre-defined effect to any of your content elements.

Add modern fx and motion to any elements of your website.

The content animator widget lets you animate any kind of content. Simply add class="animate" to any html object in your DOM and the effect will be applied to the affected element. You can setup, which effect you wish to be drawn, as well as the scroll distance to the object. Be careful to use a not too big value, otherwise your users will think, that there is no more content before it got faded in. (or whichever effect you have activated)

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 18 of file contentAnimator.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator::__construct (   $db)

Load all widget settings from database and fill object.

Parameters
object$dbDatabase Object

Load all widget settings on object init.

Definition at line 36 of file contentAnimator.php.

38  {
39  // load this widget settings from db
40  $this->widget = new \YAWK\widget();
41  $settings = $this->widget->getWidgetSettingsArray($db);
42  foreach ($settings as $property => $value) {
43  $this->$property = $value;
44  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ init()

YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator::init ( )

Initialize: prepare proerties and load javascript.

use this method to run the clock

Definition at line 61 of file contentAnimator.php.

63  {
64  // check if class is empty
65  if (!isset($this->contentAnimatorClass) || (empty($this->contentAnimatorClass)))
66  { // default behavior:
67  $this->contentAnimatorClass = "fadeIn";
68  }
69  // check if scroll value is empty
70  if (!isset($this->contentAnimatorScrollValue) || (empty($this->contentAnimatorScrollValue)))
71  { // default value
72  $this->contentAnimatorScrollValue = 600;
73  }
74  // check if infinite is set
75  if (!isset($this->contentAnimatorInfinite) || (empty($this->contentAnimatorInfinite)))
76  { // default css value
77  $this->contentAnimatorInfinite = "";
78  }
79  else
80  { // infinite is set to true
81  if ($this->contentAnimatorInfinite === "true")
82  { // set the correct value
83  $this->contentAnimatorInfinite = "infinite";
84  }
85  else
86  { // don't loop animation: leave infinite empty
87  $this->contentAnimatorInfinite = "";
88  }
89  }
90  // load velocity.js
91  // echo "<script src=\"system/engines/velocityJS/velocity.min.js\"></script>";
92  // echo "<script src=\"system/engines/velocityJS/velocity-ui.min.js\"></script>";
93 
94  // load css with animation definitions
95  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"system/widgets/contentAnimator/animate.css\">";
96  // echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"system/engines/animateCSS/animate.min.css\">";
97  // echo "<style type=\"text/css\">.animate {visibility:hidden;}</style>";
98 
99  // output JS
100  echo"<script>
101  $(document).ready(function(){
102  // Slide in elements on scroll
103  $(window).scroll(function() {
104  // on each element that go animate class
105  $('.animate').each(function()
106  {
107  // get position
108  var pos = $(this).offset().top;
109  // get window top position
110  var winTop = $(window).scrollTop();
111 
112  // user-defined params for every element
113  // if they are not filled, default widget settings will be used
114  var fx = $(this).attr(\"data-fx\"); // animation fx for this element
115  var px = $(this).attr(\"data-px\"); // px value from top for this element
116 
117  // check if custom px value is defined
118  if (px !== undefined) {
119  // set custom px value
120  contentAnimatorScrollValue = px;
121  }
122  else {
123  // set default px value from widget settings
124  contentAnimatorScrollValue = $this->contentAnimatorScrollValue;
125  }
126 
127  // animate when position is in visible area
128  if (pos < winTop + contentAnimatorScrollValue) {
129  // $(this).velocity(\"transition.fadeIn\", {duration:1000, loop:false});
130 
131  // element got custom FX values
132  if (fx !== undefined) {
133  // set animated custom fx
134  $(this).addClass('animated '+fx);
135  // remove animate class to avoid hide after animation
136  $(this).removeClass('animate');
137  }
138  else
139  { // add default fx from widget settings
140  $(this).addClass(\"$this->contentAnimatorClass\");
141  }
142  }
143  });
144  });
145  });
146 </script>";

◆ printObject()

YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator::printObject ( )

Print all object data.

(for development and testing purpose)

Definition at line 50 of file contentAnimator.php.

52  {
53  echo "<pre>";
54  print_r($this);
55  echo "</pre>";

Member Data Documentation

◆ $contentAnimatorClass

YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator::$contentAnimatorClass = 'slideUp'
Parameters
stringWhich effect should be drawn on class="animated" At the time of writing this, following effects were available: slideUp, slideDown, slideLeft, slideRight, fade, fadeMedium, fadeSlow

Definition at line 29 of file contentAnimator.php.

◆ $contentAnimatorScrollValue

YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator::$contentAnimatorScrollValue = '620'
Parameters
stringScroll distance to target which should be effected

Definition at line 24 of file contentAnimator.php.

◆ $widget

YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator::$widget = ''
Parameters
objectglobal widget object data

Definition at line 21 of file contentAnimator.php.


The documentation for this class was generated from the following file: