forked from chrishutchinson/cardkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-fix the SVG element on scroll, making for easier editing again
- Loading branch information
1 parent
c079793
commit e15a03a
Showing
5 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,21 @@ | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc directive | ||
* @name cardkitApp.directive:fixedScroll | ||
* @description | ||
* # fixedScroll | ||
*/ | ||
angular.module('cardkitApp') | ||
.directive('fixedScroll', function ($window) { | ||
return function(scope, element, attrs) { | ||
var offset = element.offset().top-20; | ||
angular.element($window).bind('scroll', function() { | ||
if(angular.element($window).scrollTop() >= offset) { | ||
element.addClass('fixed'); | ||
} else { | ||
element.removeClass('fixed'); | ||
} | ||
}); | ||
}; | ||
}); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,20 @@ | ||
'use strict'; | ||
|
||
describe('Directive: fixedScroll', function () { | ||
|
||
// load the directive's module | ||
beforeEach(module('cardkitApp')); | ||
|
||
var element, | ||
scope; | ||
|
||
beforeEach(inject(function ($rootScope) { | ||
scope = $rootScope.$new(); | ||
})); | ||
|
||
it('should make hidden element visible', inject(function ($compile) { | ||
element = angular.element('<fixed-scroll></fixed-scroll>'); | ||
element = $compile(element)(scope); | ||
expect(element.text()).toBe('this is the fixedScroll directive'); | ||
})); | ||
}); |