DOJO base/Fx has no animateProperty method
-
23-12-2019 - |
Question
I'm trying to animate the transparency change if a element using dojo/_base/fx animateProperty(). However I hit an error on console saying *Uncaught TypeError: Object # has no method 'animateProperty' *. Not able to figure out what's wrong with the code. Here's the fiddle I created for this.
Posting code snippet too:
require(["dojo/fx", "dojox/fx/scroll", "dojo/dom", "dojo/dom-style", "dojo/on", "dojo/domReady!","dojo/window","dojo/dom-geometry","dojo/dom-style", "dojo/_base/fx"],
function(coreFx, easing, dom, style, on, win, domGeometry, fx){
on(dom.byId("contactFormButton1"), "click", function(){
//dojo.byId('screen1').style.opacity = '0.5';
fx.animateProperty({
node: dom.byId("screen1"), duration: 5000,
properties: {
opacity: { start: '1', end: '0.5' }
}
}).play();
style.set("screen2", "display", "block");
dojo.byId('contactFormButton1').style.display = 'none';
dojox.fx.smoothScroll({
node: dojo.byId('screen2'),
win: window
}).play();
});
});
Solution
require([
"dojo/fx", "dojox/fx/scroll",
"dojo/dom", "dojo/dom-style", "dojo/on", "dojo/domReady!",
"dojo/window", "dojo/dom-geometry", "dojo/_base/fx"
], function (coreFx, easing, dom, style, on, ready, win, domGeometry, fx) {
on(dom.byId("contactFormButton1"), "click", function () {
//dojo.byId('screen1').style.opacity = '0.5';
fx.animateProperty({
node: dom.byId("screen1"),
duration: 5000,
properties: {
opacity: {
start: '1',
end: '0.5'
}
}
}).play();
dojo.byId('contactFormButton1').style.display = 'none';
});
});
The problem is a mismatch between the require
and function parameters. You forgot ready
as parameter.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow