Smooth scrolling, svg support via directive

This commit is contained in:
Will Marshall
2014-06-13 10:59:49 +10:00
parent 6135fe0336
commit bc93ce57e6
6 changed files with 18 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "HubsCtrl", ($scope, Hubs, $anchorScroll, $rootScope, HashNavigation) ->
Darkswarm.controller "HubsCtrl", ($scope, Hubs, $document, $rootScope, HashNavigation) ->
$scope.Hubs = Hubs
$scope.hubs = Hubs.hubs

View File

@@ -0,0 +1,10 @@
Darkswarm.directive "renderSvg", ()->
restrict: 'E'
priority: 99
template: "<svg-wrapper></svg-wrapper>"
link: (scope, elem, attr)->
if /.svg/.test attr.path # Only do this if we've got an svg
$.ajax
url: attr.path
success: (html)->
elem.html($(html).find("svg"))

View File

@@ -4,5 +4,7 @@ Darkswarm.directive 'scrollAfterLoad', ($timeout, $location, $document)->
if scope.$last is true
$(window).load ->
$timeout ->
$document.scrollTo $("##{$location.hash()}"), 100, 200, (x)->
x * (2 - x)
elem = $("##{$location.hash()}")
if elem.length > 0
$document.scrollTo elem , 100, 200, (x)->
x * (2 - x)