Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo fade animations not working
    primarykey
    data
    text
    <p>Alright I've been trying to learn Dojo here today and I just can't seem to figure out why I can't fade in my elements. What I'm doing here is loading a set of images from a json object and putting them in the DOM. I then want to fade them in one at a time using an array and the shift method. This is a working plugin I wrote in jQuery and am using as a crash course for Dojo. The wierd thing is that I can't get the fade animation to work at all, even if I strip away the array and just try to target a single DOM element, but if I paste in one of the examples from <a href="http://dojotoolkit.org/reference-guide/1.8/dojo/_base/fx.html#dojo-base-fx-fadein" rel="nofollow">here</a> directly into my webpage, that works.</p> <p>Here's the code:</p> <pre><code>define([ "dojo/query", "dojo/dom-class", "dojo/domReady!", "dojo/request", "dojo/json", "dojo/_base/fx", "dojo/on", "dojo/dom-attr", "dojo/dom-style" ], function(query, domClass, dom, request, fx, on, domAttr){ var images = new Array(); //The array object created from the XML file var cur_first = 0; //Current first image, used as a counter to determine which images should be shown var running = true; //Flag to prevent multiple firings or next/prev var display_num = 4; //Num of images displayed at a time request.get('../../javascript/json/rotator_images.js',{handleAs:'json'}).then( function(response){ for(i=0; i &lt; response.images.image.length; i++){ var src = response.images.image[i].src; var title = response.images.image[i].title; var desc = response.images.image[i].desc; var thumb = response.images.image[i].thumb; images[i]={src: src, title: title, desc: desc, thumb: thumb}; } load_images(); } ); function load_images(){ for(i=0; i &lt; images.length; i++){ if(i &gt;= cur_first &amp;&amp; i &lt; cur_first+display_num){ dojo.create("div", { innerHTML:"&lt;a class='fancybox' rel='group' href='"+images[i].src+"'&gt;&lt;img src='"+images[i].thumb+"' /&gt;&lt;/a&gt;", className:"r_image", style:{opacity:'0'}, id:"r_image_"+(i+1) },dojo.byId("images_wrap")); } } display_images(); } function remainder(){ //Find the remaining images left at the end inside our display_num control so we can determine when to start back at 0 or jump to the end var flr = Math.floor(images.length / display_num) return images.length - (flr*display_num); } query("#arrow_r").on("click", function(){ if(running == false){ running = true; if(cur_first &lt; images.length - remainder()){ cur_first = cur_first+display_num; }else{ cur_first = 0; } hide_images(); } }) query("#arrow_l").on("click", function(){ if(running == false){ running = true; if(cur_first &gt; 1){ cur_first = cur_first-display_num hide_images(); }else{ cur_first = images.length - remainder(); hide_images(); } } }) function display_images(){ var images_arr = []; dojo.query(".r_image").forEach(function(node) { images_arr.push(node); }); function fadeThemIn(images_arr) { if (images_arr.length &gt; 0) { var currentImg = images_arr.shift(); var fadeArgs = { node: currentImg, duration: 200, }; fx.fadeIn(fadeArgs).play(); }else{ running = false; } } fadeThemIn(images_arr) } } ); </code></pre> <p>Sorry about just dumping the entire code into here but I figure it has to be something with Dojo's AMD amd how the modules are being loaded (which I find a headache at this point). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload