Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added grabber html compiling (issue #27) #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion angular-resizable.min.js

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

14 changes: 10 additions & 4 deletions src/angular-resizable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('angularResizable', [])
.directive('resizable', function() {
.directive('resizable', ['$compile', '$rootScope', function($compile, $rootScope) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the unused variable $rootScope

var toCall;
function throttle(fun) {
if (toCall === undefined) {
Expand Down Expand Up @@ -40,13 +40,19 @@ angular.module('angularResizable', [])

element.addClass('resizable');

var getCompiledGrabber = function(grabber)
{
var linkFunction = $compile(angular.element(grabber));
return linkFunction(scope.$parent)[0];
};

var style = window.getComputedStyle(element[0], null),
w,
h,
dir = scope.rDirections || ['right'],
vx = scope.rCenteredX ? 2 : 1, // if centered double velocity
vy = scope.rCenteredY ? 2 : 1, // if centered double velocity
inner = scope.rGrabber ? scope.rGrabber : '<span></span>',
inner = getCompiledGrabber(scope.rGrabber ? scope.rGrabber : '<span></span>'),
start,
dragDir,
axis,
Expand Down Expand Up @@ -141,7 +147,7 @@ angular.module('angularResizable', [])

// add class for styling purposes
grabber.setAttribute('class', 'rg-' + direction);
grabber.innerHTML = inner;
grabber.appendChild(inner);
element[0].appendChild(grabber);
grabber.ondragstart = function() { return false; };

Expand All @@ -157,4 +163,4 @@ angular.module('angularResizable', [])
});
}
};
});
}]);