Jquery Effect - Advanced Animate from center

Опубликовано: 01 Октябрь 2024
на канале: optikalefx
22,551
56

Using jquery and some logic we can make some cool animations. This one shows you how to do a light box effect, which means animating from the center outward. In reality you are just animating from top left to bottom right while moving from bottom right to top left switch(open) {
case "x":
x = $(window).width()/2;
y = $(window).height()/2 - h/2;
startW = x/2 - w;
startH = h;
endTop = y;
endLeft = x - w/2;
break;
case "y":
x = $(window).width()/2 - w/2;
y = $(window).height()/2;
startW = w;
startH = y/2-h;
endTop = y - h/2;
endLeft = x;
break;
case "center":
default:
x = $(window).width()/2;
y = $(window).height()/2;
startW = h-y/2;
startH = w-x/2;
endTop = y - h/2;
endLeft = x - w/2;
break;
}