Browse Source

Fixes issue with reverse visibility callbacks not firing if normal callback not present

pull/1129/head
jlukic 10 years ago
parent
commit
cdede1506e
2 changed files with 48 additions and 36 deletions
  1. 76
      src/definitions/behaviors/visibility.js
  2. 8
      src/themes/packages/default/elements/button.variables

76
src/definitions/behaviors/visibility.js

@ -212,18 +212,20 @@ $.fn.visibility = function(parameters) {
module.save.elementCalculations();
// percentage
module.passed();
// reverse (must be first)
module.passingReverse();
module.topVisibleReverse();
module.bottomVisibleReverse();
module.topPassedReverse();
module.bottomPassedReverse();
// one time
module.passing();
module.topVisible();
module.bottomVisible();
module.topPassed();
module.bottomPassed();
// reverse
module.passingReverse();
module.topVisibleReverse();
module.bottomVisibleReverse();
module.topPassedReverse();
module.bottomPassedReverse();
},
passed: function(amount, newCallback) {
@ -260,7 +262,7 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for passing', newCallback);
settings.onPassing = newCallback;
}
if(callback && calculations.passing) {
if(calculations.passing) {
module.execute(callback, callbackName);
}
else if(!settings.once) {
@ -282,7 +284,7 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for top visible', newCallback);
settings.onTopVisible = newCallback;
}
if(callback && calculations.topVisible) {
if(calculations.topVisible) {
module.execute(callback, callbackName);
}
else if(!settings.once) {
@ -303,7 +305,7 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for bottom visible', newCallback);
settings.onBottomVisible = newCallback;
}
if(callback && calculations.bottomVisible) {
if(calculations.bottomVisible) {
module.execute(callback, callbackName);
}
else if(!settings.once) {
@ -324,7 +326,7 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for top passed', newCallback);
settings.onTopPassed = newCallback;
}
if(callback && calculations.topPassed) {
if(calculations.topPassed) {
module.execute(callback, callbackName);
}
else if(!settings.once) {
@ -345,7 +347,7 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for bottom passed', newCallback);
settings.onBottomPassed = newCallback;
}
if(callback && calculations.bottomPassed) {
if(calculations.bottomPassed) {
module.execute(callback, callbackName);
}
else if(!settings.once) {
@ -366,8 +368,10 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for passing reverse', newCallback);
settings.onPassingReverse = newCallback;
}
if(callback && !calculations.passing) {
module.execute(callback, callbackName);
if(!calculations.passing) {
if(module.get.occurred('passing')) {
module.execute(callback, callbackName);
}
}
else if(!settings.once) {
module.remove.occurred(callbackName);
@ -388,8 +392,10 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for top visible reverse', newCallback);
settings.onTopVisibleReverse = newCallback;
}
if(callback && !calculations.topVisible) {
module.execute(callback, callbackName);
if(!calculations.topVisible) {
if(module.get.occurred('topVisible')) {
module.execute(callback, callbackName);
}
}
else if(!settings.once) {
module.remove.occurred(callbackName);
@ -409,8 +415,10 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for bottom visible reverse', newCallback);
settings.onBottomVisibleReverse = newCallback;
}
if(callback && !calculations.bottomVisible) {
module.execute(callback, callbackName);
if(!calculations.bottomVisible) {
if(module.get.occurred('bottomVisible')) {
module.execute(callback, callbackName);
}
}
else if(!settings.once) {
module.remove.occurred(callbackName);
@ -430,8 +438,10 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for top passed reverse', newCallback);
settings.onTopPassedReverse = newCallback;
}
if(callback && !calculations.topPassed) {
module.execute(callback, callbackName);
if(!calculations.topPassed) {
if(module.get.occurred('topPassed')) {
module.execute(callback, callbackName);
}
}
else if(!settings.once) {
module.remove.occurred(callbackName);
@ -451,8 +461,7 @@ $.fn.visibility = function(parameters) {
module.debug('Adding callback for bottom passed reverse', newCallback);
settings.onBottomPassedReverse = newCallback;
}
if(callback && !calculations.bottomPassed) {
console.log(module.get.occurred('bottomPassed'));
if(!calculations.bottomPassed) {
if(module.get.occurred('bottomPassed')) {
module.execute(callback, callbackName);
}
@ -470,15 +479,17 @@ $.fn.visibility = function(parameters) {
calculations = module.get.elementCalculations(),
screen = module.get.screenCalculations()
;
if(settings.continuous) {
module.debug('Callback being called continuously', callbackName, calculations);
$.proxy(callback, element)(calculations, screen);
}
else if(!module.get.occurred(callbackName)) {
module.debug('Conditions met', callbackName, calculations);
$.proxy(callback, element)(calculations, screen);
callback = callback || false;
if(callback) {
if(settings.continuous) {
module.debug('Callback being called continuously', callbackName, calculations);
$.proxy(callback, element)(calculations, screen);
}
else if(!module.get.occurred(callbackName)) {
module.debug('Conditions met', callbackName, calculations);
$.proxy(callback, element)(calculations, screen);
}
}
console.log(callbackName);
module.save.occurred(callbackName);
},
@ -486,7 +497,6 @@ $.fn.visibility = function(parameters) {
occurred: function(callback) {
if(callback) {
if(module.cache.occurred[callback] !== undefined && module.cache.occurred[callback] === true) {
console.log(callback, element);
module.debug('Callback can now be called again', callback);
module.cache.occurred[callback] = false;
}
@ -500,8 +510,10 @@ $.fn.visibility = function(parameters) {
save: {
occurred: function(callback) {
if(callback) {
if(module.cache.occurred[callback] !== undefined)
module.cache.occurred[callback] = true;
if(module.cache.occurred[callback] === undefined || (module.cache.occurred[callback] !== true)) {
module.verbose('Saving callback occurred', callback);
module.cache.occurred[callback] = true;
}
}
},
scroll: function() {

8
src/themes/packages/default/elements/button.variables

@ -194,10 +194,10 @@
@basicInvertedDownBackground: @transparentWhite;
@basicInvertedActiveBackground: @transparentWhite;
@basicInvertedBoxShadow: 0px 0px 0px @invertedBorderSize #999999 inset;
@basicInvertedHoverBoxShadow: 0px 0px 0px @invertedBorderSize #FFFFFF inset;
@basicInvertedDownBoxShadow: 0px 0px 0px @invertedBorderSize #CCCCCC inset;
@basicInvertedActiveBoxShadow: 0px 0px 0px @invertedBorderSize #DADADA inset;
@basicInvertedBoxShadow: 0px 0px 0px @invertedBorderSize rgba(255, 255, 255, 0.5) inset;
@basicInvertedHoverBoxShadow: 0px 0px 0px @invertedBorderSize rgba(255, 255, 255, 1) inset;
@basicInvertedDownBoxShadow: 0px 0px 0px @invertedBorderSize rgba(255, 255, 255, 0.9) inset;
@basicInvertedActiveBoxShadow: 0px 0px 0px @invertedBorderSize rgba(255, 255, 255, 0.7) inset;
@basicInvertedColor: @darkWhite;
@basicInvertedHoverColor: @darkWhiteHover;

Loading…
Cancel
Save