jQuery for animating border radius

◇◆丶佛笑我妖孽 提交于 2019-12-10 16:25:39

问题


I have a problem animating border-top-left-radius style. I use this style by entering two length values separately.

border-top-left-radius: 15px 25px;

I would like to increase these two length values separately via jquery.animate().

Is there a way to achieve this?


回答1:


border-top-left-radius accepts just one value right? So you would animate it like:

$('.class').animate({borderTopLeftRadius: 20})

EDIT


Not sure if jQuery supporst this out of the box. Maybe you can implement the step callback like this:

$('#container').animate({
    borderTopLeftRadiusSideLength: 500,
    borderTopLeftRadiusUpperLength: 50
}, {
    duration: 5000,
    step: function (val, context) {
        $(this).data(context.prop, val);
        var side = $(this).data('borderTopLeftRadiusSideLength');
        var upper = $(this).data('borderTopLeftRadiusUpperLength');
        if (side && upper) {
            $(this).css('borderTopLeftRadius', side + 'px ' + upper + 'px');
        }
    }
});

http://jsfiddle.net/YWsQn/1/



来源:https://stackoverflow.com/questions/13551857/jquery-for-animating-border-radius

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!