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)

View File

@@ -5,7 +5,7 @@
Shop for
%p.trans-sentence
%span.fat-taxons{"ng-repeat" => "taxon in hub.taxons"}
%object.taxon{"ng-attr-data" => "{{taxon.icon}}", type: "image/svg+xml"}
%render-svg{path: "{{taxon.icon}}"}
{{taxon.name}}
.columns.small-4
%h5 Delivery options

View File

@@ -3,9 +3,7 @@
%img{"bo-src" => "product.master.images[0].small_url"}
.small-4.columns.summary-header
%object.taxon{"ng-attr-data" => "{{product.primary_taxon.icon}}", type: "image/svg+xml",
"ng-click" => "ordering.order = 'primary_taxon.name'"}
{{taxon.name}}
%render-svg{path: "{{product.primary_taxon.icon}}"}
= render partial: "modals/product"
.small-5.columns

View File

@@ -36,6 +36,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
exchange.variants << product.master
visit shop_path
save_screenshot "/users/willmarshall/Desktop/wtsvg.png"
find("#tab_producers a").click
page.should have_content supplier.name
end