Last active
December 11, 2015 17:38
-
-
Save MacDada/4635367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.bindingHandlers.canvasContext = { | |
init: function(element, valueAccessor, allBindingsAccessor, viewModel) { | |
if ("undefined" === typeof viewModel.__canvasContexts__) { | |
viewModel.__canvasContexts__ = []; | |
} | |
// works now :) | |
if ("function" !== typeof element.getContext && FlashCanvas) { | |
FlashCanvas.initElement(element); | |
} | |
// sharing canvas context with VM – useful when debugging | |
viewModel.__canvasContexts__.push(element.getContext("2d")); | |
}, | |
update: function(element, valueAccessor, allBindingsAccessor, viewModel) { | |
var callback = ko.utils.unwrapObservable(valueAccessor()); | |
callback.call(viewModel, element.getContext("2d")); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment