Skip to content

Commit

Permalink
[refactored] ParallaxDemo to use JSS instead of AttachStreams
Browse files Browse the repository at this point in the history
Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion

Tags: #material_motion

Differential Revision: http://codereview.cc/D3489
  • Loading branch information
appsforartists committed Nov 30, 2018
1 parent ae27dad commit 18e9d60
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 186 deletions.
151 changes: 0 additions & 151 deletions packages/demos-react/src/JSSDemo.tsx

This file was deleted.

55 changes: 26 additions & 29 deletions packages/demos-react/src/ParallaxDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

import * as React from 'react';

import { create as createJSS, StyleSheet } from 'jss';
import createDefaultJSSPreset from 'jss-preset-default';

import {
Axis,
Draggable,
Expand All @@ -35,18 +38,22 @@ import {
viewportDimensions$,
} from 'material-motion';

import {
AttachStreams,
} from './AttachStreams';

import {
TransformTarget,
} from './TransformTarget';
const jss = createJSS(createDefaultJSSPreset());

export class ParallaxDemo extends React.Component<{}, {}> {
foregroundStyle$ = createProperty({ initialValue: {} });
backgroundStyle$ = createProperty({ initialValue: {} });

styleSheet = jss.createStyleSheet(
{
foreground: this.foregroundStyle$,
background: this.backgroundStyle$,
},
{
link: true,
},
).attach();

attachInteractions = (element: HTMLElement | null) => {
if (element) {
const {
Expand Down Expand Up @@ -80,9 +87,8 @@ export class ParallaxDemo extends React.Component<{}, {}> {

render() {
const {
backgroundStyle$,
foregroundStyle$,
} = this;
classes,
} = this.styleSheet;

return (
<div
Expand All @@ -97,25 +103,14 @@ export class ParallaxDemo extends React.Component<{}, {}> {
}
}
>
<AttachStreams
style = { backgroundStyle$ }
>
<TransformTarget>
<RandomClouds
scale = { 3 }
/>
</TransformTarget>
</AttachStreams>

<AttachStreams
style = { foregroundStyle$ }
>
<TransformTarget>
<RandomClouds
scale = { 5 }
/>
</TransformTarget>
</AttachStreams>
<RandomClouds
className = { classes.background }
scale = { 3 }
/>
<RandomClouds
className = { classes.foreground }
scale = { 5 }
/>
</div>
);
}
Expand All @@ -129,11 +124,13 @@ class RandomClouds extends React.Component<{ scale: number }, {}> {

render() {
const {
className,
scale,
} = this.props;

return (
<div
className = { className }
style = {
{
position: 'relative',
Expand Down
6 changes: 0 additions & 6 deletions packages/demos-react/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Router from 'react-router/BrowserRouter';

// import ExampleMain from './example/components/ExampleMain';
import ArticulableFinger from './ArticulableFinger';
import JSSDemo from './JSSDemo';
import ParallaxDemo from './ParallaxDemo';
import QuickiePointerEventTest from './QuickiePointerEventTest';
import SwipeableDemo from './SwipeableDemo';
Expand Down Expand Up @@ -57,11 +56,6 @@ const links = [
name: 'ParallaxDemo',
component: ParallaxDemo,
},
{
href: '/parallax-jss/',
name: 'JSSDemo',
component: JSSDemo,
},
{
href: '/pointer-events/',
name: 'QuickiePointerEventTest',
Expand Down

0 comments on commit 18e9d60

Please sign in to comment.