Skip to content

Commit

Permalink
Avoid use of NativeMethodsMixin
Browse files Browse the repository at this point in the history
	* #7
  • Loading branch information
SoHotSoup committed Dec 1, 2016
1 parent 848e8cf commit 8ccdb9b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Parallax.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component, } from 'react';
import NativeMethodsMixin from 'react/lib/NativeMethodsMixin';
import { Animated, View, Dimensions } from 'react-native';
import React, { Component } from 'react';
import ReactNative, { Animated, View, Dimensions, UIManager } from 'react-native';

const findNodeHandle = ReactNative.findNodeHandle;

import { DriverShape } from './DriverShape';
/*
Expand Down Expand Up @@ -79,9 +80,11 @@ export class Parallax extends Component {
}

measure() {
NativeMethodsMixin.measure.call(this, (x, y, width, height, pageX, pageY) => {
const handleMeasure = (x, y, width, height, pageX, pageY) => {
this.setState({ x: pageX, y: pageY });
});
};

UIManager.measure(findNodeHandle(this), handleMeasure);
}

componentDidMount() {
Expand All @@ -97,7 +100,12 @@ export class Parallax extends Component {

componentWillMount() {
const { driver } = this.props;
driver.value.addListener(this.calculateTranslation);
this.animationListener = driver.value.addListener(this.calculateTranslation);
}

componentWillUnmount() {
const { driver } = this.props;
driver.value.removeListener(this.animationListener);
}

render() {
Expand Down

0 comments on commit 8ccdb9b

Please sign in to comment.