diff --git a/app/assets/javascripts/darkswarm/directives/scroll_after_load.js.coffee b/app/assets/javascripts/darkswarm/directives/scroll_after_load.js.coffee index 55c5a311da..e29dcbb8f8 100644 --- a/app/assets/javascripts/darkswarm/directives/scroll_after_load.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/scroll_after_load.js.coffee @@ -2,10 +2,9 @@ Darkswarm.directive 'scrollAfterLoad', ($timeout, $location, $document)-> # Scroll to an element on page load restrict: "A" link: (scope, element, attr) -> - if scope.$last is true - $(window).load -> - $timeout -> - elem = $("##{$location.hash()}") - if elem.length > 0 - $document.scrollTo elem , 100, 200, (x)-> - x * (2 - x) + elem = element + $(window).load -> + $timeout -> + if elem? + $document.scrollTo elem, 100, 200, (x) -> + x * (2 - x) diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index 1e5151469e..7b10a50b17 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -1,8 +1,9 @@ -= inject_enterprises += inject_enterprises + #hubs.hubs{"ng-controller" => "EnterprisesCtrl"} .row .small-12.columns - %h1 Shop in your local area + %h1{"scroll-after-load" => (spree_current_user ? true : nil)} Shop in your local area = render partial: "shared/components/enterprise_search" = render partial: "home/filters" @@ -12,7 +13,6 @@ .active_table %hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredEnterprises = (Enterprises.hubs | visible | searchEnterprises:query | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | orderBy:['-active', '+orders_close_at'])", "ng-class" => "{'is_profile' : hub.category == 'hub_profile', 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}", - "scroll-after-load" => true, "ng-controller" => "HubNodeCtrl", id: "{{hub.hash}}"} .small-12.columns diff --git a/app/views/producers/index.html.haml b/app/views/producers/index.html.haml index 3dbbfe9fbb..cb9c3d3826 100644 --- a/app/views/producers/index.html.haml +++ b/app/views/producers/index.html.haml @@ -15,7 +15,6 @@ .small-12.columns .active_table %producer.active_table_node.row.animate-repeat{id: "{{producer.path}}", - "scroll-after-load" => true, "ng-repeat" => "producer in filteredEnterprises = (Enterprises.producers | visible | searchEnterprises:query | taxons:activeTaxons)", "ng-controller" => "ProducerNodeCtrl", "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",