This commit is contained in:
2017-12-25 20:23:32 +01:00
parent 1175a4f8ff
commit 0cc882060c
36 changed files with 781 additions and 86 deletions
+7 -9
View File
@@ -20,16 +20,14 @@ $(function(){
ko.bindingHandlers.fadeVisible = {
init : function ( element, valueAccessor ) {
// Initially set the element to be instantly visible/hidden depending on the value
var value = valueAccessor();
$( element ).toggle( ko.unwrap( value ) ); // Use "unwrapObservable" so we can handle values that may or may not be observable
init: function(element, valueAccessor) {
var shouldDisplay = valueAccessor();
$(element).toggle(shouldDisplay);
},
update: function ( element, valueAccessor ) {
// Whenever the value subsequently changes, slowly fade the element in or out
var value = valueAccessor();
ko.unwrap( value ) ? $( element ).fadeIn( 500 ) : $( element ).fadeOut( 500 );
update: function(element, valueAccessor) {
// On update, fade in/out
var shouldDisplay = valueAccessor();
shouldDisplay ? $(element).fadeIn(750) : $(element).fadeOut(750);
}
};