Skip to content

Instantly share code, notes, and snippets.

@frankier
Last active December 25, 2015 00:09
Show Gist options
  • Save frankier/6885461 to your computer and use it in GitHub Desktop.
Save frankier/6885461 to your computer and use it in GitHub Desktop.
<?php if (!preg_match('|^/_|', $_SERVER['REQUEST_URI'])): ?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script>
"use strict";
var last_url, next_url;
var app = angular.module('app', []).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/:url', {
templateUrl: function(url) {
console.log(url.url);
last_url = next_url;
next_url = url.url;
return '/_/'+url.url;
}
});
$locationProvider.html5Mode(true);
}]);
app.animation('foo-enter', function() {
return {
setup: function(element) {
element.css({'opacity': 0});
},
start : function(element, done) {
element.animate({
'opacity' : 1
}, function() {
done();
});
}
};
});
app.animation('foo-leave', function() {
return {
setup: function(element) {
},
start : function(element, done) {
element.slideUp(500, done);
}
};
});
app.animation('bar-enter', function() {
return {
setup: function(element) {
},
start : function(element, done) {
element.slideDown(500, done);
}
};
});
app.animation('bar-leave', function() {
return {
setup: function(element) {
element.css({'opacity': 1});
},
start : function(element, done) {
element.animate({
'opacity' : 0
}, function() {
done();
});
}
};
});
function viewController($scope) {
$scope.next_anim = function() {
return {
enter: next_url + '-enter',
leave: last_url + '-leave'
};
}
}
</script>
<body ng-app="app">
<a href="/foo">foo</a>
<a href="/bar">bar</a>
<a href="/baz">baz</a>
<div id=changeme ng-view ng-controller="viewController" ng-animate=" next_anim() "></div>
<?php else: ?>
<?php sleep(3); ?>
<h1><?php echo $_SERVER['REQUEST_URI']; ?></h1>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment