Skip to content

Commit

Permalink
clean up some unused variables and compress the minified script
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegreiling committed Jan 29, 2015
1 parent e504c7a commit 374a749
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}

if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
window.requestAnimationFrame = function(callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
Expand All @@ -37,9 +37,6 @@

// Parallax Constructor

var $body = $('body');
var $window = $(window);

function Parallax(element, options) {
var self = this;

Expand Down Expand Up @@ -263,19 +260,20 @@
setup: function() {
if (this.isReady) return;

$window
.on('scroll.px.parallax load.px.parallax', function() {
var $doc = $(document), $win = $(window);

$win.on('scroll.px.parallax load.px.parallax', function() {
var scrollTopMax = Parallax.docHeight - Parallax.winHeight;
var scrollLeftMax = Parallax.docWidth - Parallax.winWidth;
Parallax.scrollTop = Math.max(0, Math.min(scrollTopMax, $window.scrollTop()));
Parallax.scrollLeft = Math.max(0, Math.min(scrollLeftMax, $window.scrollLeft()));
Parallax.scrollTop = Math.max(0, Math.min(scrollTopMax, $win.scrollTop()));
Parallax.scrollLeft = Math.max(0, Math.min(scrollLeftMax, $win.scrollLeft()));
Parallax.requestRender();
})
.on('resize.px.parallax load.px.parallax', function() {
Parallax.winHeight = $window.height();
Parallax.winWidth = $window.width();
Parallax.docHeight = $(document).height();
Parallax.docWidth = $(document).width();
Parallax.winHeight = $win.height();
Parallax.winWidth = $win.width();
Parallax.docHeight = $doc.height();
Parallax.docWidth = $doc.width();
Parallax.isFresh = false;
Parallax.requestRender();
});
Expand Down
2 changes: 1 addition & 1 deletion parallax.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 374a749

Please sign in to comment.