开发者

Is there built in support to increment an attribute by x

When we set animateProperty开发者_StackOverflow in dojo, can we do this

dojo.animateProperty({
  node:byId("ss"),
  property: { left: "+=100" }
});

How can this be made. Want to move the container 100px to the RIGHT ... from the current position.


dojox.fx have a lot of extra animations that some people often use. If you want to slide a node relative from its current position you can use dojox.fx.slideBy(). A complete example with loading the class and waiting for dom-ready event.

dojo.require("dojox.fx");
dojo.ready(function(){
    dojox.fx.slideBy({
        node:     dojo.byId('slide'),
        duration: 2000,
        top:      100,
        left:     -50
    }).play();
});

This will slide the node with id slide 100px down, and 50px to the left.


There's no built-in support for this, so you'll have to manually get the original position first.

dojo.animateProperty({
    node: "ss",
    properties: {
         left: function(node){
             return node.style.offsetLeft + 100;
         }
    }
});

Here's a thread in the Dojo forums about it.


onAnimate callback can be right place where we can determine the current style property value, instead of getting the style property value from node.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜