Skip to content

Instantly share code, notes, and snippets.

@bdkent
Last active December 5, 2015 03:26
Show Gist options
  • Save bdkent/ddb200bb465fb78333e7 to your computer and use it in GitHub Desktop.
Save bdkent/ddb200bb465fb78333e7 to your computer and use it in GitHub Desktop.
Tour Starter Hack
<div ui-tour ... >
<tour-starter tour="tour" delay-ms="2000"></tour-starter>
...
</div>
function TourStarterDirective($timeout) {
function TourStarterPostLinker($scope, $element, iAttrs, controller) {
var isReady = false;
var isStarted = false;
function refresh() {
if (!isReady) {
isReady = !!$scope.tour;
}
if (isReady && !isStarted) {
$timeout(function () {
$scope.tour.start();
isStarted = true;
}, $scope.delayMs);
}
}
$scope.$watch('tour', refresh);
refresh();
}
return {
restrict: 'E',
scope: {
'tour': '=',
'delayMs': '@'
},
link: TourStarterPostLinker
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment