Question: I have a sql statement

```
SELECT emp.id, emp.name, 
FROM emp, office, payment
WHERE emp.id = office.empid 
AND payment.id = emp.pay

```

but I actually want the 

```
 AND payment.id = emp.pay

```

to be executed conditionally. It should not execute always. For e.g. it should execute only if emp.pay is NOT NULL

Answer: 
You can add animation on all styles changes adding next properties to **myDiv** class:

```
/* Animate all changes */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;

```

I will show the changes on your example:

```js
$('.myDiv').click(function(e)
{
    $(this).toggleClass('fullscreen');
});
```

```css
.myDiv{
    background:#cc0000;
    width:100px;
    height:100px;
    float:left:
    margin:15px;

    /*Animations*/
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;   
}

.myDiv.fullscreen{
    z-index: 9999; 
    width: 100%; 
    height: 100%; 
    position: fixed; 
    top: 0; 
    left: 0; 
 }
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="myDiv">
    my div 1
    <button>Full Screen</button>
</div>

<div class="myDiv">
    my div 2 
    <button>Full Screen</button>
</div>
```
It's a bit of a complicated task, but this should give you an idea of how it's done. This code will run into some issues (clicking quickly will stack `setTimeout`) but does the basics.

The idea is that you calculate the current position of the element with `getBoundingClientRect()` and set initial position values with that, so that when you adjust the position to `fixed`, it will look as though it's still in the same spot - then when you override those values with the `.fullscreen` css, the `transition` property will allow them to animate.

The biggest issue here, which you'll notice if you click on the first div, is that it disappears from the layout and causes the second div to jump up to where it was, you'd probably need a way of preserving the layout. Hopefully this is helpful as a starting point anyway.

```js
function getPosition(elem){
  const rect = elem.getBoundingClientRect()
  return {
    top: rect.top,
    left: rect.left,
    width: rect.width,
    height: rect.height
  }
}

function toPx(val){
  return [val, 'px'].join('')
}

$('.myDiv').click(function(e){
  if(this.classList.contains('fullscreen')){
    this.classList.remove('fullscreen')
    setTimeout(e => this.style.position = 'static', 1000)
    //close
  } else {
    //open
    let pos = getPosition(this)
    this.style.width = toPx(pos.width)
    this.style.height = toPx(pos.height)
    this.style.top = toPx(pos.top)
    this.style.left = toPx(pos.left)
    console.log(pos)
    this.classList.add('fullscreen')
    this.style.position = 'fixed'
  }
});
```

```css
.myDiv{background:#cc0000; width:100px; height:100px;float:left:margin:15px;}

.myDiv.fullscreen{
    z-index: 9999; 
    width: 100% !important; 
    height: 100% !important;
    top: 0 !important;
    left: 0 !important; 
 }

 .animateTransitions {
  transition: all 1s;
 }
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="myDiv animateTransitions">
               my div
              <button>Full Screen</button>
   </div>

   <div class="myDiv animateTransitions">
               my div 2 
              <button>Full Screen</button>
   </div>
```