Showing posts with label left. Show all posts
Showing posts with label left. Show all posts

Monday, 29 October 2012

Halloween - Jquery, Animate, Top, Left, End of Animation

Here is a quick halloween example, this can obviously be improved, but should help out people get a basic understanding of how to repeat a jquery animation. This is a simple example with a tranparent ghost png.

<style>
body {
background::#000;
overflow-x: hidden;
overflow-y: scroll;
background-color: #000;
}

#ghost {
background:url(img/ghost.png) transparent;
height:128px;
width:128px;
position:absolute;
left:-128px;
overflow:hidden;
}
</style>

<script language="javascript" src="js/jquery-1.8.2.min.js"></script>

<script>

$(document).ready(function () {

function ghost(div){

$(div).css("left","-128px");

// Fading Start
$(div).fadeTo(5000, Math.random(), function() {
// Animation complete.
});
// Fading End

$(div).animate({
left: "+=" + ($("body").width() + 140),
top: (Math.ceil(Math.random()*500)),

},
5000,
function() {
var randomize = Math.ceil(Math.random() * 10000);
setTimeout(function() { ghost(div)},randomize);
}
);

}

ghost("#ghost");

});

</script>

Take note of where "function() {" is within .animate as it allows you to callback once the animation is completed.

Thursday, 7 July 2011

Natural/Alternative Ordering in MS SQL Server

Its been a long time since I have posted, but here we go

After lots of messing about I finally found a solution the for the problem of ordering using an example someone else provided as well a little bit of tinkering.


Results BEFORE:
CH10
CH1001
CH400
CH50
G99

Results AFTER:
catno
CH10
CH50
CH400
CH1001
G99

Example
SELECT * FROM mycats ORDER BY left(catno,2), RIGHT(REPLICATE('0', 1000) + LTRIM(RTRIM(CAST(catno AS VARCHAR(MAX)))), 1000)