Skip to content

Adding "move" event #4

ghost opened this Issue Mar 1, 2010 · 3 comments

1 participant

ghost commented Mar 1, 2010

I was looking for simple "move" event without a complete freeze, like faking a mouse move - useful for controlling parallax position by buttons or triggered events. Here is the code (insert anywhere into big query on "layers" object):

return layers
.bind("move", function(e){
var elem = jQuery(this),
local =,
mouse = local.mouse || local.freeze || global.mouse,
x = regex.percent.exec(e.x) ? parseFloat(e.x.replace(/%$/, ''))/100 : (e.x || mouse.pointer[0]) ,
y = regex.percent.exec(e.y) ? parseFloat(e.y.replace(/%$/, ''))/100 : (e.y || mouse.pointer[1]);

    // Fake the mouse
    global.mouse.ontarget = false;

    // Start animating
    .bind(frameEvent, global, update);

Arguments are the same as for "freeze". Decay was useless for me but it could be added easily.



My approach to this problem was to freeze and then unfreeze on mouseenter:

.trigger({type: 'freeze', x: 2, y: 2});

.bind('mouseenter', function(e){

However, I can see how a 'move' event would be a lot more concise. I think that can go in ...



Note the code above suffers from Issue 5 - 0 values will not work.

ghost commented Mar 2, 2010

"Move" does not work in IE, it behave quirky. Only one animation step happens on move() call, so it takes multiple calls to actually move layers to final destination. Only IE's are affected, will investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.