Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #9 from NealEhardt/master
Browse files Browse the repository at this point in the history
Use `translate`, not `translate3d`
  • Loading branch information
aputinski committed Mar 2, 2016
2 parents c16077a + 81a8988 commit b030822
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/dist
npm-debug.log
npm-debug.log
/.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ A function can be used to perform custom transitions:
navigationController.pushView(<MyView />, {
transition(prevElement, nextElement, done) {
// Do some sort of animation on the views
prevElement.style.transform = 'translate3d(100%, 0, 0)';
nextElement.style.transform = 'translate3d(0, 0, 0)';
prevElement.style.transform = 'translate(100%, 0)';
nextElement.style.transform = 'translate(0, 0)';
// Tell the navigationController when the animation is complete
setTimeout(done, 500);
}
Expand Down
20 changes: 8 additions & 12 deletions spec/navigation-controller.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ import rebound from 'rebound';
import NavigationController from '../src/navigation-controller';
import View from '../examples/src/view';

import { getVendorPrefix } from '../src/util/dom';

const { Transition } = NavigationController;

const transformPrefix = getVendorPrefix('transform');

class ViewA extends View { }
class ViewB extends View { }
class ViewC extends View { }
Expand Down Expand Up @@ -94,8 +90,8 @@ describe('NavigationController', () => {
});
describe('#componentDidMount', () => {
it('transforms the view wrappers', () => {
expect(viewWrapper0).to.have.deep.property(`style.${transformPrefix}`);
expect(viewWrapper1).to.have.deep.property(`style.${transformPrefix}`);
expect(viewWrapper0).to.have.deep.property(`style.transform`);
expect(viewWrapper1).to.have.deep.property(`style.transform`);
});
});
describe('#__transformViews', () => {
Expand All @@ -107,8 +103,8 @@ describe('NavigationController', () => {
it('translates the views', (done) => {
controller.__transformViews(10, 20, 30, 40);
requestAnimationFrame(() => {
expect(viewWrapper1.style[transformPrefix]).to.equal(`translate3d(10%, 20%, 0px)`);
expect(viewWrapper0.style[transformPrefix]).to.equal(`translate3d(30%, 40%, 0px)`);
expect(viewWrapper1.style.transform).to.equal(`translate(10%, 20%)`);
expect(viewWrapper0.style.transform).to.equal(`translate(30%, 40%)`);
done();
});
});
Expand Down Expand Up @@ -356,13 +352,13 @@ describe('NavigationController', () => {
transition(prevElement, nextElement, done) {
_prevElement = prevElement;
_nextElement = nextElement;
prevElement.style[transformPrefix] = 'translate3d(10px, 20px, 0px)';
nextElement.style[transformPrefix] = 'translate3d(30px, 40px, 0px)';
prevElement.style.transform = 'translate(10px, 20px)';
nextElement.style.transform = 'translate(30px, 40px)';
setTimeout(done, 500);
},
onComplete() {
expect(_prevElement.style[transformPrefix]).to.equal(`translate3d(10px, 20px, 0px)`);
expect(_nextElement.style[transformPrefix]).to.equal(`translate3d(30px, 40px, 0px)`);
expect(_prevElement.style.transform).to.equal(`translate(10px, 20px)`);
expect(_nextElement.style.transform).to.equal(`translate(30px, 40px)`);
done();
}
});
Expand Down
17 changes: 0 additions & 17 deletions spec/util/dom.spec.js

This file was deleted.

8 changes: 2 additions & 6 deletions src/navigation-controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import rebound from 'rebound';
import classNames from 'classnames';

import { getVendorPrefix } from './util/dom';
import { dropRight, last, takeRight } from './util/array';
import { assign } from './util/object';

Expand All @@ -18,9 +17,6 @@ const {
mapValueInRange
} = rebound.MathUtil;


const transformPrefix = getVendorPrefix('transform');

const optionTypes = {
pushView: {
view: React.PropTypes.element.isRequired,
Expand Down Expand Up @@ -132,9 +128,9 @@ class NavigationController extends React.Component {
const prevView = this.refs[`view-wrapper-${prev}`];
const nextView = this.refs[`view-wrapper-${next}`];
requestAnimationFrame(() => {
prevView.style[transformPrefix] = `translate3d(${prevX}%,${prevY}%,0px)`;
prevView.style.transform = `translate(${prevX}%,${prevY}%)`;
prevView.style.zIndex = Transition.isReveal(this.state.transition) ? 1 : 0;
nextView.style[transformPrefix] = `translate3d(${nextX}%,${nextY}%,0px)`;
nextView.style.transform = `translate(${nextX}%,${nextY}%)`;
nextView.style.zIndex = Transition.isReveal(this.state.transition) ? 0 : 1;
});
}
Expand Down
21 changes: 0 additions & 21 deletions src/util/dom.js

This file was deleted.

0 comments on commit b030822

Please sign in to comment.