All Projects → techjacker → Backbone Responsive Css3 Page Transitions

techjacker / Backbone Responsive Css3 Page Transitions

Licence: mit
CSS3 hardware accelerated page transitions optimised for fluid layouts

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Backbone Responsive Css3 Page Transitions

Page Transitions Travelapp
Travel App, Native-like Page Transitions
Stars: ✭ 1,637 (+4714.71%)
Mutual labels:  animations, page-transitions
React Native Nav Transition
React Native Nav Transition
Stars: ✭ 154 (+352.94%)
Mutual labels:  mobile, animations
Page Transitions Travelapp
Travel App, Native-like Page Transitions
Stars: ✭ 134 (+294.12%)
Mutual labels:  animations, page-transitions
Construcao De Paginas Web
Desenvolvimento de páginas semânticas, acessíveis e responsivas. 🚀
Stars: ✭ 113 (+232.35%)
Mutual labels:  animations, css3
React Native Dating App
Dating app - Exponent and React Native
Stars: ✭ 352 (+935.29%)
Mutual labels:  mobile, animations
H5ui
Lightweight, elegant open source mobile UI style library.
Stars: ✭ 44 (+29.41%)
Mutual labels:  mobile, css3
Lazy
Kule Lazy4 / CSS Framework
Stars: ✭ 147 (+332.35%)
Mutual labels:  mobile, css3
Dynamic.css
🚀 Awesome Library of CSS3 animations 🎉
Stars: ✭ 38 (+11.76%)
Mutual labels:  css3, animations
ionic-modal-custom-transitions
Add Custom Transitions to Ionic Modals.
Stars: ✭ 22 (-35.29%)
Mutual labels:  animations, page-transitions
learn-css-animation
Learn CSS animation with fun. It is simple, easy to use, and fun to learn.
Stars: ✭ 54 (+58.82%)
Mutual labels:  css3, animations
Push State
Turn static web sites into dynamic web apps.
Stars: ✭ 16 (-52.94%)
Mutual labels:  animations, page-transitions
Nextjs Page Transitions
Travel App, Native-like Page Transitions (:atom: with React & Next.js)
Stars: ✭ 424 (+1147.06%)
Mutual labels:  animations, page-transitions
Font Awesome Animation
Simple animations using FontAwesome and some CSS3.
Stars: ✭ 856 (+2417.65%)
Mutual labels:  animations, css3
Masterportfolio
🔥 The Complete Customizable Software Developer Portfolio Template which lets you showcase your work and provides each and every detail about you as Software Developer.
Stars: ✭ 913 (+2585.29%)
Mutual labels:  css3
React Prismazoom
A pan and zoom component for React, using CSS transformations.
Stars: ✭ 29 (-14.71%)
Mutual labels:  css3
Magma
Platform for building access networks and modular network services
Stars: ✭ 913 (+2585.29%)
Mutual labels:  mobile
Flutter countdown timer
Flutter countdown timer with the propper animations
Stars: ✭ 21 (-38.24%)
Mutual labels:  animations
Aaviewanimator
AAViewAnimator is a set of animations designed for UIView, UIButton, UIImageView with options in iOS, written in Swift.
Stars: ✭ 33 (-2.94%)
Mutual labels:  animations
Grav Theme Landio
Land.io is a carefully crafted landing page UI kit and landing page template built on Bootstrap 4, designed by Peter Finlan and developed by Taty Grassini.
Stars: ✭ 28 (-17.65%)
Mutual labels:  css3
House
A runtime mobile application analysis toolkit with a Web GUI, powered by Frida, written in Python.
Stars: ✭ 910 (+2576.47%)
Mutual labels:  mobile

Backbone Responsive CSS3 Page Transitions

Build Status

Adds responsive* CSS3 page transitions to backbone.

  • Works on Chrome 12+, Safari 4+, Firefox 14+, ie 10+, Android 2.1+
  • Lightweight: 3k (minified + gzipped)
  • Require.js AMD compatible
  • Falls back to replacing page content if the browser does not support CSS3 translate3d transformations (eg opera)

***** *This plugin does not magically make fixed width layouts into responsive ones. Coding a responsive CSS layout is a prerequisite to using the plugin *****

Responsive CSS Framework Demos

Tested to work with the following reponsive CSS frameworks:

  1. twitter bootstrap responsive
  2. foundation responsive
  3. skeleton
  4. simplegrid

Install via Package Manager

Grab from Jam.js:

[email protected]:~$ jam install backbone.responsiveCSS3transitions

or Bower:

[email protected]:~$ bower install backbone.responsiveCSS3transitions

Plugins

iScroll4 Plugin

  • iScroll plugin available the github repo
  • plugin compatible with v0.3+
  • useful for ensuring that page transitions always load the new page scrolled to the top
  • smoother page transitions that avoid scroll "jumps"

Getting Started

1. Load the Javascript and CSS

	<link rel="stylesheet" href="scripts/vendor/backbone.responsiveCSS3transitions.min.css"/>
</head>

<body>
	<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>

	<script src="backbone.responsiveCSS3transitions.min.js"></script>

AMD

Backbone Dependency

Plugin relies upon 'backbone' as a dependency. Make sure that this is set up in your require.js shim config.

Fastclick Dependency

If you want to use the fastclick functionality with an AMD set up then you should set up your shim config as with backbone and then edit the AMD definition in backbone.responsiveCSS3transitions.js

//...... top of backbone.responsiveCSS3transitions.js file
define(['backbone'], factory);
// if using fastclick then replace the line above with this:
// define(['backbone', 'fastclick'], factory);

2. HTML Set Up: Wrapping Divs

Either: 1. wrap your container div with the wrapping divs needed manually

<div class="threeDTrans-outmost-page-container">
	<div class="threeDTrans-page-container">

		<!-- your container -->
		<div class="my-container threeDTrans-page"">
			<p>my amazing website...</p>
		</div>

	</div>
</div>

Or 2. Specify the jquery selector of the containing element when initiliasing the router

var threeDRouter = backboneResponsiveCSS3Transitions.extend({....});
var my Router = new threeDRouter({"wrapElement": ".my-container"});

3. Make your router inherit from backboneResponsiveCSS3Transitions instead of Backbone.Router

var threeDRouter = backboneResponsiveCSS3Transitions.extend({...});
new threeDRouter();

// your view....
var myBackboneView = Backbone.View.extend({
	className: 'my-container',
	render: function () {
		this.$el.html('the html of the new page to be inserted');
	}
});

// your router class loading your view
var threeDRouter = backboneResponsiveCSS3Transitions.extend({
	routes: {
		"*default": "loadView",
	},
	loadView: function (viewFragment) {
		// ...
		this.triggerTransition(myBackboneView, options);
	}
});

// your app instantiaing the router
app = {
	// ...
	init: function() {
		new threeDRouter(options);
		Backbone.history.start();
	}
}
app.init();

Router Instantiation Options

@param {options}
  • accepts: object
@param {options.renderCallback}
  • accepts: boolean
  • description: make the page transitions wait for the render event to be emitted before triggering the page animation. Useful if you're loading templates with ajax.
// ... set the renderCallback option to true when initialising your router
var threeDRouter = backboneResponsiveCSS3Transitions.extend({....});
threeDRouter = new threeDRouter({"renderCallback": true});

// ...in your view class...
var myBackboneView = Backbone.View.extend({
	// ...
	render: function () {
		// ...
		this.trigger('render');
	}
});
@param {options.wrapElement}
  • accepts: boolean
  • description: the jquery selector of the html element that contains your content. If you want the js to take care of adding the wrapping divs then set this. **** If you choose this option then the html element must be present on the page when the router is instantiated. If it is inside one of your backbone views that hasn't been loaded onto the page yet on first page load then it will fail miserably ****
var threeDRouter = backboneResponsiveCSS3Transitions.extend({....});
new threeDRouter({"wrapElement": ".my-container"});
@param {options.fastClick}
  • accepts: fastClick function/constructor

  • description: assign the function you want to call on links in order to remove click delay on touch devices, I recommend fastclick.js Eg:

      // include lib in index.html
      <script src="scripts/vendor/fastclick.js"></script>
    
      // in your js
      new threeDRouter({"fastClick": window.FastClick});
    

4. Use this.triggerTransition(ViewClass, options) in your router's routes' callbacks to trigger the page transition

var threeDRouter = backboneResponsiveCSS3Transitions.extend({
	initialize: function (opts) {
		// ...
	},
	routes: {
		"*default": "loadView",
	},

	loadView: function (viewFragment) {

		// ... your own route logic here
		// @param {ViewClass} (mandatory) > the backbone view class that you want to load
		// @param {options}
		this.triggerTransition(ViewClass, options);
	}
});

Parameters

ViewClass

The backbone view class of the new page to be inserted. It's render method will be called before inserting it into the new page.

@param {viewClass}
  • accepts: Backbone View Class

options object

@param {options}
  • accepts: object
@param {options.viewInitOps}
  • accepts: object
  • description: passed as the options object when instantiating the new view
@param {options.renderParams}
  • accepts: any type
  • description: passed as params when calling the new view render's method
@param {options.direction}
  • accepts: string ("backwards", "forwards", "default")
  • description: manually override direction calculation by supplying your own value default = just swaps the new page html without applying a sliding transition

Events

The 'threeDTrans.pageTransitionComplete' event is triggered by the router when the page transition is complete.

5. Direction of the page transition

The direction is automatically calculated based upon comparing the folder depths of the new and previous url hashes. The default is no transition ie just replace html.

  • backwards: moving from #sports/football/premiership to #sports
  • forwards: moving from #sports to #sports/football
  • default: moving from #sports/football to #sports/rugby

You can manually override this by specifying the direction yourself when calling the this.triggerTransition() method, eg:

var threeDRouter = backboneResponsiveCSS3Transitions.extend({
	// ...
	routes: {
		"*default": "loadView",
	},
	loadView: function (viewFragment) {
		if (viewFragment.match(/foobar/)) {
			this.triggerTransition(myView, {"direction": "forwards"});
		} else {
			this.triggerTransition(myView);
		}
	}
});

Example Code

	<!-- ... -->
	<link rel="stylesheet" href="scripts/vendor/backbone.responsiveCSS3transitions.min.css"/>
</head>

<body>
	<!-- ... -->

	<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>

	<script src="backbone.responsiveCSS3transitions.min.js"></script>

	<script>
	var threeDRouter = backboneResponsiveCSS3Transitions.extend({
		initialize: function (opts) {
			// ...
		},
		routes: {
			// ... your own route logic here
			"*default": "loadView",
		},
		loadView: function (viewFragment) {

			var myBackboneView = Backbone.View.extend({
				className: 'my-container',
				template: 'application.ejs',
				loadTemplate: function (vars, name, dir) {
					var self = this;
					vars = vars || {};
					dir = dir || 'scripts/templates/';
					name = name || this.template;
					return $.get(dir + name).pipe(function (tmpl) {
						tmpl = _.template(tmpl);
						self.$el.html(tmpl(vars));
						self.trigger('render');
					});
				},
				render: function () {
					this.loadTemplate({ foo: urlParams});
				}
			}),
			options = {
				direction: "forwards",
				renderParams: "imprenderParams",
				viewInitOps: {
					"yourImportantViewInitUpVars" : "here"
				}
			};

			// ... your own route logic here

			this.triggerTransition(myBackboneView, options);
		}
	});

	var options = {
			"renderCallback": true,
			"wrapElement": ".my-container"
		},
	myRouter = new threeDRouter(options);

	Backbone.history.start();

	</script>
</body>

Centered Designs with outer gutters

As used in all the demos.

Apply the margins to the target wrapping element, eg:

// specify the wrapping div when instantiating the router...
new threeDRouter({"wrapElement": ".my-container"});

in your stylesheet...

.my-container {
	width: 94%;
	margin: 0 3%;
}

Caveats / Gotchas / Why isn't it working???

  1. Ensure that your Backbone Views have a render method The backboneResponsiveCSS3Transitions will insert the new view.$el into the page once it has called the render method. If your view emits a render event and you would like the page animation to be delayed until this is emitted then set this an option when instantiating the router.
  2. The router takes care of inserting the views on to the page - do not include this logic in your views!
  3. If the browser does not support CSS3 transitions then they fall back to just plain old $el.html('new html') replacing html.
  4. If you want the js to take care of adding the wrapping divs then the html element must be present on the page when the router is instantiated.
  5. The wrapping element's immediate children should have 100% width for gutter effect to work ie this works
	.wrapper {width: 90%; margin: 0 auto;}
	.child {width:auto;}

ie this WON'T work

	.wrapper {width: 100%;}
	.child {padding:0 15%;}

Tests

Run the tests via command line:

$ npm install
$ npm test

Run the tests via browser:

  1. fire up a node http server

     $ node server.js
    
  2. go to http://0.0.0.0:8124/test.html

To do

  • Add iOS support

Release History

  • 0.1.0
  • 0.2.0 - Added Android Support
  • 0.2.1 - Added FastClick functionality + fixed ie10 bug
  • 0.3.0 - Added iScroll plugin compatibility (released as separate plugin)
  • 0.3.1 - Render callback bug fix
  • 0.3.2-3 - Add travis CI
  • 0.3.4 - Update dev dependencies
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].