|
374 | 374 | if (targetPointer[0] === prevPointer[0] && targetPointer[1] === prevPointer[1]) { |
375 | 375 | return; |
376 | 376 | } |
377 | | - |
378 | | - return updateFn(targetPointer); |
| 377 | + |
| 378 | + // Pass the responsibility for updating back to "pointerOffTarget" now that we're off the target again. |
| 379 | + portElem.trigger('parallax.setPointerFn', [pointerOffTarget]); |
379 | 380 | } |
380 | 381 |
|
381 | 382 | function unport(elem, events, winEvents) { |
|
441 | 442 | timer.add(frame); |
442 | 443 | timer.start(); |
443 | 444 | }, |
| 445 | + |
444 | 446 | 'mouseleave.parallax': function mouseleave(e) { |
445 | 447 | // Make the layer come to rest at it's limit with inertia |
446 | 448 | pointerFn = pointerOffTarget; |
447 | 449 | // Stop the timer when the the pointer hits target |
448 | 450 | targetFn = targetOutside; |
449 | | - } |
| 451 | + }, |
| 452 | + |
| 453 | + // TODO: Needed to set this up as an event listener due to scope issues. |
| 454 | + 'parallax.setPointerFn': function setPointerFn(e, newPointerFn) { |
| 455 | + pointerFn = newPointerFn; |
| 456 | + } |
450 | 457 | }; |
451 | 458 |
|
452 | 459 | function updateCss(newPointer) { |
|
456 | 463 | } |
457 | 464 |
|
458 | 465 | function frame() { |
459 | | - pointerFn(port.pointer, pointer, port.threshold, decay, parallax, targetFn, updateCss); |
| 466 | + // TODO: Might make sense to eventually refactor calls to pointerFN to simply pass the port instance. |
| 467 | + // TODO: Also to have the entire initialization to be based on a jQuery set of just the port [port] and |
| 468 | + // TODO: pass the layers as an option instead of the other way around, i.e. [layer, layer, ...] |
| 469 | + pointerFn(port.pointer, pointer, port.threshold, decay, parallax, targetFn, updateCss, elem); |
460 | 470 | } |
461 | 471 |
|
462 | 472 | function targetInside() { |
|
0 commit comments