Created
February 20, 2015 14:54
-
-
Save henrahmagix/c1759660f251006e23d7 to your computer and use it in GitHub Desktop.
Canvas angular module beginnings
This file contains hidden or 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
(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