Currently, I am working on a page where I need to make an element draggable.
Upon clicking on the element, I add the 'active' class which expands the div along with the image inside it.
Initially, the div is structured as...
<div class="work-showcase">
After clicking, it changes to...
<div class="work-showcase active">
I want to create a condition where if the div has the class 'active', then perform function X, otherwise perform function Y.
$(body).click(function(){
if($('.work-showcase').hasClass('active')){
var bleft = 4900 ;
var bright = $(window).width() - 200;
$('.active > ul li').draggable({
axis: "x",
revert: false,
stop: function(event, ui) {
if(ui.position.left < -bleft)
{
$(this).animate({"left": "0px"}, 600);
}
if(ui.position.left > bright)
{
$(this).animate({"left": "0px"}, 600);
}
}
});
} else {
var sleft = 1846 ;
var sright = $(window).width() - 200;
$('.work-showcase > ul li').draggable({
axis: "x",
revert: false,
stop: function(event, ui) {
if(ui.position.left < -sleft)
{
$(this).animate({"left": "0px"}, 600);
}
if(ui.position.left > sright)
{
$(this).animate({"left": "0px"}, 600);
}
}
});
}
});
However, I am facing an issue with my If statement not functioning as expected...