I would like the div to run this animation while the mouse travels on the timeline. The div starts with width/height 100px when the mouse approaching the half of timeline, the div been resized simultaneously to width/height 200px. and when the mouse gets closer to the end of the timeline returns to div width/height 100px.
$('#timeline').mousemove(function(e){
var position = e.clientX;
$('#mark').css("left", position - 50);
});
$('#animation').animate({
width: "200",
height: "200"
}, 2000).animate({
width: 100,
height: 100
}, 2000);
Please suggest.
You need to do some
Math, baby! Specifically, theabsfunction can be used to work out how far from the mid-point you are. Use the following to work out the distance from the centreline:Your final function would then look something like this:
Hope that helps!