<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Javascript quark #2: fading out in Vuforia Studio</title>
    <link>https://www.ptcusercommunity.com/t5/Vuforia-Studio/Javascript-quark-2-fading-out/m-p/585612#M6081</link>
    <description>&lt;P&gt;This is the second Javascript quark in the series: it can be used to fade a widget out. You can find the first quark &lt;A href="https://community.ptc.com/t5/Studio-Tech-Tips/Javascript-quark-1/m-p/584530/highlight/true#M64" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's the code to copy &amp;amp; paste&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to your&amp;nbsp;&lt;STRONG&gt;H&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;ome.js&lt;/STRONG&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;$scope.fadeOut = function(widget, time, interval) {
  let w = (widget.opacity !== undefined ? widget : $scope.view.wdg[widget]);
  if (time &amp;lt;= 0 || interval &amp;lt;= 0 || w.opacity === undefined) { throw "Cannot fade this widget"; }
  let steps = Math.floor(time / interval);
  let opDelta = w.opacity / steps;
  return $interval(() =&amp;gt; w.opacity = (opDelta &amp;lt; w.opacity) ? (w.opacity - opDelta) : 0, interval, steps);
}&lt;/PRE&gt;
&lt;P&gt;This quark will make the widget fade out from its current opacity to 0 in time milliseconds, uniformly decrementing opacity at every interval .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Invoke the function like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;fadeOut(widget, time, interval);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;STRONG&gt;widget&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is either the id of the widget (e.g.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" size="2"&gt;modelItem-1&lt;/FONT&gt;) or the widget itself (e.g.&amp;nbsp;&lt;FONT face="courier new,courier" size="2"&gt;$scope.view.wdg['modelItem-1']&lt;/FONT&gt;), &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;time&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;represent the total time it takes to fade the widget out from its current opacity, and &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;interval&lt;/FONT&gt;&lt;/STRONG&gt; represents the amount of time between each&amp;nbsp;opacity change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;fadeOut('modelItem-1', 2000, 50);&lt;/PRE&gt;
&lt;P&gt;This example fades the model item out by bringing its current opacity to zero after 2 seconds with an opacity change every 50 ms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Comments and suggestions are welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Alessio&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Dec 2018 11:28:25 GMT</pubDate>
    <dc:creator>Alessio</dc:creator>
    <dc:date>2018-12-18T11:28:25Z</dc:date>
    <item>
      <title>Javascript quark #2: fading out</title>
      <link>https://www.ptcusercommunity.com/t5/Vuforia-Studio/Javascript-quark-2-fading-out/m-p/585612#M6081</link>
      <description>&lt;P&gt;This is the second Javascript quark in the series: it can be used to fade a widget out. You can find the first quark &lt;A href="https://community.ptc.com/t5/Studio-Tech-Tips/Javascript-quark-1/m-p/584530/highlight/true#M64" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's the code to copy &amp;amp; paste&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to your&amp;nbsp;&lt;STRONG&gt;H&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;ome.js&lt;/STRONG&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;$scope.fadeOut = function(widget, time, interval) {
  let w = (widget.opacity !== undefined ? widget : $scope.view.wdg[widget]);
  if (time &amp;lt;= 0 || interval &amp;lt;= 0 || w.opacity === undefined) { throw "Cannot fade this widget"; }
  let steps = Math.floor(time / interval);
  let opDelta = w.opacity / steps;
  return $interval(() =&amp;gt; w.opacity = (opDelta &amp;lt; w.opacity) ? (w.opacity - opDelta) : 0, interval, steps);
}&lt;/PRE&gt;
&lt;P&gt;This quark will make the widget fade out from its current opacity to 0 in time milliseconds, uniformly decrementing opacity at every interval .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Invoke the function like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;fadeOut(widget, time, interval);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" size="3"&gt;&lt;STRONG&gt;widget&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is either the id of the widget (e.g.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" size="2"&gt;modelItem-1&lt;/FONT&gt;) or the widget itself (e.g.&amp;nbsp;&lt;FONT face="courier new,courier" size="2"&gt;$scope.view.wdg['modelItem-1']&lt;/FONT&gt;), &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;time&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;represent the total time it takes to fade the widget out from its current opacity, and &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;interval&lt;/FONT&gt;&lt;/STRONG&gt; represents the amount of time between each&amp;nbsp;opacity change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;fadeOut('modelItem-1', 2000, 50);&lt;/PRE&gt;
&lt;P&gt;This example fades the model item out by bringing its current opacity to zero after 2 seconds with an opacity change every 50 ms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Comments and suggestions are welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Alessio&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2018 11:28:25 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Vuforia-Studio/Javascript-quark-2-fading-out/m-p/585612#M6081</guid>
      <dc:creator>Alessio</dc:creator>
      <dc:date>2018-12-18T11:28:25Z</dc:date>
    </item>
  </channel>
</rss>

