Skip to content

Commit

Permalink
add mobile support
Browse files Browse the repository at this point in the history
  • Loading branch information
orifn committed Jul 24, 2017
1 parent 533d5f8 commit 280993e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions ng-croppie.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
/**
* Crops, rotates and zooms the image to this element
*
* 20170406 orif-jr - Added modularized code procedure
* 20170724 orif-jr - Added mobile support
* 20170720 orif-jr - Enhanced watchers for src and rotation
* 20170406 orif-jr - Added modularized code procedure
*/
module.directive('ngCroppie', ['$timeout', function ($timeout) {
return {
Expand All @@ -34,7 +35,8 @@
exif: '@',
orientation: '@',
update: '=',
ngModel: '='
ngModel: '=',
mobile: '@'
},
link: function (scope, elem, attr) {
// defaults
Expand All @@ -46,10 +48,17 @@
}

// catches
scope.viewport.w = (scope.viewport.w != undefined) ? scope.viewport.w : 300;
scope.viewport.h = (scope.viewport.h != undefined) ? scope.viewport.h : 300;
scope.boundry.w = (scope.boundry.w != undefined) ? scope.boundry.w : 400;
scope.boundry.h = (scope.boundry.h != undefined) ? scope.boundry.h : 400;
if (scope.mobile === true) {
scope.viewport.w = (scope.viewport.w != undefined) ? scope.viewport.w : 200;
scope.viewport.h = (scope.viewport.h != undefined) ? scope.viewport.h : 250;
scope.boundry.w = (scope.boundry.w != undefined) ? scope.boundry.w : 250;
scope.boundry.h = (scope.boundry.h != undefined) ? scope.boundry.h : 300;
} else {
scope.viewport.w = (scope.viewport.w != undefined) ? scope.viewport.w : 300;
scope.viewport.h = (scope.viewport.h != undefined) ? scope.viewport.h : 300;
scope.boundry.w = (scope.boundry.w != undefined) ? scope.boundry.w : 400;
scope.boundry.h = (scope.boundry.h != undefined) ? scope.boundry.h : 400;
}

// viewport cannot be larger than the boundaries
if (scope.viewport.w > scope.boundry.w) {
Expand Down
2 changes: 1 addition & 1 deletion ng-croppie.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 280993e

Please sign in to comment.