I have the following code:
index
<div id="app" ng-controller="AppCtrl">
<div id="container" ng-controller="PageCtrl">
<div ng-repeat="page in pages" id="{{page.prop_id}}">
<ng-include src="page.template" />
</div>
</div>
JSON
[
{
"prop_id" : "FORD0109",
"prop_title" : "Lorem Ipsum",
"prop_postcode" : "",
"prop_price" : "",
"prop_image" : "",
"prop_desc" : "Lorem Ipsum",
"template" : "views/prop_no_thumbs.html",
"info_image" : "",
"duration" : "4000"
}
]
controller
var presentation = angular.module("Presentation", ['ngResource']);
function AppCtrl($scope, $http) {
$http.get('json/pages.json').success(function (data) {
$scope.pages = data;
});
$scope.animateToId = function (id, container, duration) { //the id to animate, the easing type
id = "#" + id;
var $container = $(container); //define the container to move
var left = $(id).position().left;
var animSpeed = 2000; //set animation speed
var ease = "easeOutQuart";
$container.stop().animate({"left":-(left)}, animSpeed, ease);
}
}
function MenuCtrl($scope) {
//placeholder for Menu actions
}
function PageCtrl($scope) {
//placeholder for Page actions
}
All of the above code works fine when a have a call to the animateToID()
function on a ng-click
.
I need this to automatically start sliding through the templates using the duration values that appear in the pages JSON file. Once all the items in the JSON have completed, start again through the same array.