Skip to content

Instantly share code, notes, and snippets.

@henrahmagix
Created February 20, 2015 14:54
Show Gist options
  • Save henrahmagix/c1759660f251006e23d7 to your computer and use it in GitHub Desktop.
Save henrahmagix/c1759660f251006e23d7 to your computer and use it in GitHub Desktop.
Canvas angular module beginnings
(function (angular, _) {
'use strict';
var module = angular.module('canvas', [
'swipe'
]);
// In your article:
// <div canvas-circle value="0" min="0" max="100"></div>
app.directive('canvasCircle', [
'swipe',
function (swipe) {
return {
restrict: 'A',
scope: {
value: '=',
min: '=',
max: '='
},
// Include any wrapper elements or controls in this template.
templateUrl: 'templates/canvas/circle.html',
// Link is when the directive is in the DOM.
link: function (scope, element, attrs) {
var startCoords;
var lastCoords;
// scope.value is 0
// scope.min is 0
// scope.max is 100
swipe.bind(element, {
start: function (coords, event) {
// touchstart
// Set things to their defaults.
startCoords = coords;
lastCoords = startCoords;
},
move: function (coords, event) {
// touchmove
// Update things to the new position.
lastCoords = coords;
},
end: function (coords, event) {
// touchend
// This is when the user stops touching.
},
cancel: function (coords, event) {
// touchcancel
// This is when the user stops touching.
}
});
}
};
}
]);
}(window.angular, window._));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment