Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX for #87: Ensure each layer is initialized properly at correct origin x/y on page load. #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion js/jquery.parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,26 @@

port.elem.on(events);
port.layers = port.layers? port.layers.add(node): jQuery(node);


// Initialize this layer at the defined x/y origins now. Subsequent calls to this "pointerFn" will happen
// via the Timer class in repeated calls to the frame() function as the mouse either enter/leaves the
// viewport (a.k.a. "mouseport").
pointerFn(
// Pointer relative position (0 to 1), x and y. Usually in the middle (i.e. 0.5, 0.5)
[options.xorigin, options.yorigin],
[0, 0], // Pointer relative position we're trying to animate to (0 to 1), x and y.
port.threshold,
0, // Decay, which we want to override so we initialize immediately.
parallax,
targetFn,
updateCss
);

// Also if the mouse happens to already be over the viewport, trigger an initial "mouseenter" now (since
// otherwise user would need to move mouse completely out of the viewport and then back in, in order to
// initialize the effect when it should already be started).
if (elem.is(':hover')) elem.mouseenter();

/*function freeze() {
freeze = true;
}
Expand Down