Last active
December 5, 2015 03:26
-
-
Save bdkent/ddb200bb465fb78333e7 to your computer and use it in GitHub Desktop.
Tour Starter Hack
This file contains hidden or 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
<div ui-tour ... > | |
<tour-starter tour="tour" delay-ms="2000"></tour-starter> | |
... | |
</div> |
This file contains hidden or 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
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