Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(ionNavAnimation): `<a href="#/page" ion-nav-animation="slide-in-…
…up">`
- Loading branch information
Showing
5 changed files
with
82 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
angular.module('ionic.ui.navAnimation', []) | ||
.directive('ionNavAnimation', function() { | ||
return { | ||
restrict: 'A', | ||
require: '^?ionNavView', | ||
link: function($scope, $element, $attrs, navViewCtrl) { | ||
if (!navViewCtrl) { | ||
return; | ||
} | ||
ionic.on('tap', function() { | ||
navViewCtrl.setNextAnimation($attrs.ionNavAnimation); | ||
}, $element[0]); | ||
} | ||
}; | ||
}); |
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,41 @@ | ||
describe('ionNavAnimation directive', function() { | ||
beforeEach(module('ionic.ui.navAnimation')); | ||
|
||
var navViewCtrl; | ||
function setup(anim, noNavViewCtrl) { | ||
if (noNavViewCtrl) { | ||
navViewCtrl = null; | ||
} else { | ||
navViewCtrl = { | ||
setNextAnimation: jasmine.createSpy('setNextAnimation') | ||
}; | ||
} | ||
var element = angular.element( | ||
'<div ion-nav-animation="'+(anim||'')+'"></div>' | ||
); | ||
element.data('$ionNavViewController', navViewCtrl); | ||
inject(function($compile, $rootScope) { | ||
$compile(element)($rootScope.$new()); | ||
}); | ||
|
||
return element; | ||
} | ||
|
||
it('should not listen for tap if no navViewCtrl', function() { | ||
spyOn(ionic, 'on'); | ||
setup('', true); | ||
expect(ionic.on).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should listen for tap', function() { | ||
spyOn(ionic, 'on'); | ||
var el = setup(''); | ||
expect(ionic.on).toHaveBeenCalledWith('tap', jasmine.any(Function), el[0]); | ||
}); | ||
|
||
it('should call navViewCtrl.setNextAnimation on tap', function() { | ||
var el = setup('foobar'); | ||
ionic.trigger('tap', { target: el[0] }); | ||
expect(navViewCtrl.setNextAnimation).toHaveBeenCalledWith('foobar'); | ||
}); | ||
}); |
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